Geometry/Polygon/137.cpp
// line segment p-q intersect with line A-B.
line segment p-q intersect with line A-B.
line segment p - q intersect with line A - B .
point lineIntersectSeg(point p, point q, point A, point B) {
      double a = B.y - A.y;
      double b = A.x - B.x;
      double c = B.x * A.y - A.x * B.y;
      double u = fabs(a * p.x + b * p.y + c);
      double v = fabs(a * q.x + b * q.y + c);
      return point((p.x * v + q.x * u) / (u+v), (p.y * v + q.y * u) / (u+v));
}
point lineIntersectSeg ( point p , point q , point A , point B ) { double a = B . y - A . y ; double b = A . x - B . x ; double c = B . x * A . y - A . x * B . y ; double u = fabs ( a * p . x + b * p . y + c ) ; double v = fabs ( a * q . x + b * q . y + c ) ; return point ( ( p . x * v + q . x * u ) / ( u + v ) , ( p . y * v + q . y * u ) / ( u + v ) ) ; }
line segment p-q intersect with line A-B.
line segment p - q intersect with line A - B .