/// <summary> Determines whether the current line intersects the specified line. </summary> public virtual bool Intersects(Line line) { Point intersection = FindExtrapolatedIntersection(this, line); if (double.IsNaN(intersection.X)) return false;//they're parallel //the intersection may be on the extrapolation of the specified line, and is checked by the Contains method: return line.Contains(intersection); }
/// <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 current line intersects the specified line. </summary> public virtual bool Intersects(Line line) { Point intersection = FindExtrapolatedIntersection(this, line); if (double.IsNaN(intersection.X)) { return(false); //they're parallel } //the intersection may be on the extrapolation of the specified line, and is checked by the Contains method: return(line.Contains(intersection)); }
/// <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)); }