public bool CollidesWith(LineSegment lineSegment) { var axisA = new Line(Point1, Point2.Substract(Point1)); if (axisA.OnOneSide(lineSegment)) { return false; } var axisB = new Line(lineSegment.Point1, lineSegment.Point2.Substract(lineSegment.Point1)); if (axisB.OnOneSide(this)) { return false; } if (axisA.Direction.IsParallel(axisB.Direction)) { Range rangeA = ProjectOnto(axisA.Direction); Range rangeB = lineSegment.ProjectOnto(axisA.Direction); return rangeA.Overlaps(rangeB); } return true; }