Example #1
0
Coord findIntersection(LineSegment& one, LineSegment& two, double extrapolatePercentage)
{
  // extrapolate both lines out by making new segments that are larger

  one.normalize(); two.normalize(); // A < B
  
  // line one
  double ext1 = extrapolatePercentage*one.length();
  Coord A1 (one.A.x-ext1, one.A.y-ext1*one.slope());
  Coord B1 (one.B.x+ext1, one.B.y+ext1*one.slope());
  LineSegment L1 (A1, B1);

  // line one
  double ext2 = extrapolatePercentage*two.length();
  Coord A2 (two.A.x-ext2, two.A.y-ext2*two.slope());
  Coord B2 (two.B.x+ext2, two.B.y+ext2*two.slope());
  LineSegment L2 (A2, B2);
  
  // lines are now ready for intersection check
  return findIntersection(L1, L2, false);
}