public bool Intersects(AABox2D thisBox, Line2D otherLine, AABox2D otherBox) => thisBox.Intersects(otherBox) && TouchesOrCrosses(otherLine) && otherLine.TouchesOrCrosses(this);
public bool Intersects(Line2D other) { // Inspired by: https://martin-thoma.com/how-to-check-if-two-line-segments-intersect/ return(Intersects(BoundingBox(), other, other.BoundingBox())); }
public bool TouchesOrCrosses(Line2D other) => IsPointOnLine(other.A) || IsPointOnLine(other.B) || (IsPointRightOfLine(other.A) ^ IsPointRightOfLine(other.B));