title: How to insert "k" number of points between two points in C++?
body: <p>I have two curves with an equal number of data points. I want to connect the corresponding points on the curves with "k" equally spaced points to form a straight line.</p>
  
  <p><a href="https://github.com/aakarnik/Images/blob/master/Curves.png" rel="nofollow noreferrer">How it should look</a></p>
  
  <p>I have tried to use the following formula to calculate both x's and y's lying on the path between the points:</p>
  
  <pre><code>    for(int j = 1; j&lt;=num_k; j++) {
          for (int i = 2; i &lt;= (num_points-1); i++) {
              x[i][j] = x[i][1] * (1. - j/num_k) +  x[i][num_points] * j/num_k;
              y[i][j] = y[i][1] * (1. - j/num_k) +  y[i][num_points] * j/num_k;
          }
      }
  </code></pre>
  
  <p>The data points of the curve are stored in the first and last columns of 2D arrays <code>x</code> and <code>z</code>.
  <code>num_k</code> is the number of intervals I want. <code>num_points</code> is the number of points on both the curves.</p>
  
  <p>But this is not giving me the result that I need - this gives me the points, but they are not between the two input points as given. Am I using the right technique or is there something else I should be using? Also, are there any special cases? </p>
  
  <p>Thanks!!</p>