title: How do I break a non-straight line into even segments?
body: <p>I have a non-straight line defined by a series of x, y coordinate points.  I could draw a straight line on-screen directly between these points with no problem.  Unfortunately, I have to draw the line in segments of equal length.  </p>
  
  <p>Here is an example of how I need to break up a non-straight line with 3 points into an array of several equidistant points.  (ignore the final red dot, it is the result when a line does not divide evenly and is also the terminus)</p>
  
  <p><img src="https://i.stack.imgur.com/tNQ70.png" alt="Here is an example of how I need to break up a non-straight line with 3 points into an array of several equidistant points"></p>
  
  <p>Please notice the red line at the "joint".  Consider that I have a line A->B->C with the vectors AB and BC forming some angle.  Basically, the line bends at point B.</p>
  
  <p>Segmenting a line between point A and B is no problem up to a point.  But when AB does not divide evenly by the segment length, I need to do something special.  I need to take that remaining length and consider it as one side of a triangle.  The constant segment length is another side of a triangle that connects with the BC segment (the red line above).  I need to know the length from point B to this intersection.  With this information, I can continue calculating line segments on BC.</p>
  
  <p><a href="http://upload.wikimedia.org/wikipedia/commons/4/49/Triangle_with_notations_2.svg" rel="nofollow noreferrer">Here is the triangle I am trying to solve</a> (hereafter I will refer to the variables as they appear on this picture)
  So far I have broken down the problem to using the law of cosines.  c<sup>2</sup> = a<sup>2</sup> + b<sup>2</sup> - 2ab * Cos(<em>y</em>) </p>
  
  <p>The problem is that I already know c, it is the segment length.  I need to solve for a (I can calculate y).</p>
  
  <p>I've gotten as far as writing a polynomial equation, but now I am stuck:
  a<sup>2</sup> + b<sup>2</sup> - 2ab * Cos(<em>y</em>) - c<sup>2</sup> = 0</p>
  
  <p>or Ax<sup>2</sup> + Bx + C (A = 1, B = -2b * Cos(<em>y</em>), C = b<sup>2</sup> - c<sup>2</sup>, x = a)</p>
  
  <p>Is this even the right approach?  What do I do next?  I need to implement this in Actionscript.</p>
  
  <p>EDIT: Duh, I would have to use the quadratic formula.  So I now get:</p>
  
  <p>a = b * Cos(<em>y</em>) +/- SqrRoot(c<sup>2</sup> - b<sup>2</sup> * Sin(<em>y</em>)<sup>2</sup>)</p>
  
  <p>Now how to put this into code...</p>