/// <summary> Determines whether the current line segment intersects the specified line. </summary> public override bool Intersects(Line other) { if (!(other is LineSegment)) return other.Intersects(this);//this simpler case is handled by the base class Point intersection = FindExtrapolatedIntersection(this, other); if (double.IsNaN(intersection.X)) return false;//the lines are parallel //the intersection may lie on the extrapolation of the segments. To check that they are within the boundaries, the contains method is invoked for each segment return this.Contains(intersection) && other.Contains(intersection); }
/// <summary> Determines whether the specified line is equal to the current. </summary> public override bool Equals(Line other) { if (other is LineSegment) return this.Equals((LineSegment)other); return false; }