title: Using linear interpolation to animate a line moving from point A to point B
body: <pre><code>struct Point{
      float x;
      float y;
  };
  </code></pre>
  
  <p>Using this struct I made 4 points, and assigned them values. The instances of the <code>Points</code> are then used to create the lines shown in the picture.</p>
  
  <pre><code>PO.x = -0.5f;
  PO.y = 0.5f;
  
  P1.x = -1.0f;
  P1.y = -0.5f;
  
  Q0.x = 0.5;
  Q0.y = -1.0f;
  
  Q1.x = 0.7f;
  Q1.y = 0.1f;
  
  glPushMatrix();
  
  glLineWidth(2.5);
  glColor3f(1.0, 0.0, 0.0);
  glBegin(GL_LINES);
  glVertex2f(PO.x, PO.y);//PO
  glVertex2f(P1.x, P1.y);//P1
  
  glVertex2f(Q0.x, Q0.y);//QO
  glVertex2f(Q1.x, Q1.y);//Q1
  glEnd();
  
  glPopMatrix();
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/yCJtf.png" alt="Edited picture"></p>
  
  <p>The dotted lines should be the transition from points P0 to Q0 and so fourth.</p>
  
  <p>What I do understand is the concept of this technique, LERP, creates in-between frames between the two lines (or Key frame). What I do not understand is how it works. </p>
  
  <pre><code>x = x_start + ((x_final - x_start) * time)// where time is a value between zero and one
  </code></pre>
  
  <p>The above is the formula for this technique, but how will I implement this into my glut application?</p>
  
  <p>Could not find any sources online that use GLUT and LERP to demonstrate animation.</p>