Geometry/Points and Lines/378.cpp
// return true + intersection point if two lines are intersectio
return true + intersection point if two lines are intersectio
return true + intersection point if two lines are intersectio
bool areIntersect(line l1, line l2, point &p) {
    if (areParallel(l1, l2)) return false;
    p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
    if (fabs(l1.b) > EPS) p.y = -(l1.a * p.x + l1.c);
    else p.y = -(l2.a * p.x + l2.c);
    return true;
}
bool areIntersect ( line l1 , line l2 , point & p ) { if ( areParallel ( l1 , l2 ) ) return false ; p . x = ( l2 . b * l1 . c - l1 . b * l2 . c ) / ( l2 . a * l1 . b - l1 . a * l2 . b ) ; if ( fabs ( l1 . b ) > EPS ) p . y = - ( l1 . a * p . x + l1 . c ) ; else p . y = - ( l2 . a * p . x + l2 . c ) ; return true ; }
return true + intersection point if two lines are intersectio
return true + intersection point if two lines are intersectio
// solve system of two linear algebraic equations with 2 unkowns // special case: test for vertical line to avoid division by zero