예제 #1
0
 /**
  * Get the intersection point between two lines
  *
  *      y = (A1 * x) + B1  &&  y = (A2 * x) + B2
  *      x = (B2 - B1) / (A1 - A2)
  *
  * @param   \Maths\Geometry\Line    $line1
  * @param   \Maths\Geometry\Line    $line2
  * @return  \Maths\Geometry\Point
  */
 public static function getLinesIntersection(Line $line1, Line $line2)
 {
     $div = $line1->getSlope() - $line2->getSlope();
     $x = $div != 0 ? ($line2->getYIntercept() - $line1->getYIntercept()) / $div : $line2->getYIntercept() - $line1->getYIntercept();
     $y = $line1->getOrdinateByAbscissa($x);
     return new Point($x, $y);
 }