Skip to main content

segments_intersect

Function segments_intersect 

Source
pub fn segments_intersect(a: Point, b: Point, c: Point, d: Point) -> bool
Expand description

2つの閉線分 ab と cd が交差するか判定します。

端点での接触や同一直線上の重なりも交差に含めます。計算量は O(1) です。 長さ0の線分も扱えます。交点の座標や交差の種類は返しません。

§Examples

use atcoder::geometry::{segments_intersect, Point};

assert!(segments_intersect(
    Point::new(0, 0),
    Point::new(2, 2),
    Point::new(0, 2),
    Point::new(2, 0),
));