internal PointSet2(LineSegment2 <T> item) { if (item == null) { throw new ArgumentNullException(); } this.Points = new Point2 <T>[] { item.Start, item.End }; }
public bool Equals(LineSegment2 <T> other) { if (other == null) { return(false); } return(this.Start.Equals(other.Start) && this.End.Equals(other.End)); }
public static double Length(LineSegment2 <double> seg) { if (seg == null) { return(double.NaN); } return(Length(seg.Start, seg.End)); }
public static LineSegment2IntersectionResult <double> ComputeIntersection(LineSegment2 <double> segmentP, LineSegment2 <double> segmentQ) { if (segmentP == null || segmentQ == null) { return(new LineSegment2IntersectionResult <double>()); } return(ComputeIntersection(segmentP.Start, segmentP.End, segmentQ.Start, segmentQ.End)); }
public LineSegment2(LineSegment2 <T> other) { if (other == null) { throw new ArgumentNullException(); } this.Start = other.Start; this.End = other.End; }
public static bool HasIntersection(LineSegment2 <double> segmentP, LineSegment2 <double> segmentQ) { if (segmentP == null || segmentQ == null) { return(false); } LineSegment2IntersectionResult <double> tmp = ComputeIntersection(segmentP.Start, segmentP.End, segmentQ.Start, segmentQ.End); return(tmp.IntersectionType != LineIntersectionType.NoIntersection); }
public bool EqualsNonDirectional(LineSegment2 <T> other) { if (this.Start.Equals(other.Start)) { return(this.End.Equals(other.End)); } if (this.End.Equals(other.Start)) { return(this.Start.Equals(other.End)); } return(false); }
public static LineIntersectionType ComputeIntersectionType(LineSegment2 <double> segment, Point2 <double> p) { if (segment == null || p == null) { return(LineIntersectionType.NoIntersection); } // do between check first, since it is faster than the orientation test if (PointInEnvelope(segment.Start, segment.End, p)) { if ((OrientationIndex(segment.Start, segment.End, p) == 0) && (OrientationIndex(segment.End, segment.Start, p) == 0)) { return(LineIntersectionType.PointIntersection); } } return(LineIntersectionType.NoIntersection); }
public int CompareTo(LineSegment2 <T> other) { Point2 <T> min; Point2 <T> max; if (this.Start.CompareTo(this.End) < 0) { min = this.Start; max = this.End; } else { min = this.End; max = this.Start; } Point2 <T> minO; Point2 <T> maxO; if (other.Start.CompareTo(other.End) < 0) { minO = other.Start; maxO = other.End; } else { minO = other.End; maxO = other.Start; } if (max.CompareTo(minO) <= 0) { return(-1); //max of this is <= min of that } else if (min.CompareTo(maxO) >= 0) { return(1); //min of this is >= max of that } return(min.CompareTo(minO)); //partially overlap }
public static string ToWkt(LineSegment2 <double> geom) { if (geom != null) { StringBuilder sb = new StringBuilder(); sb.Append("LINESTRING("); sb.Append(geom.Start.X); sb.Append(' '); sb.Append(geom.Start.Y); sb.Append(','); sb.Append(geom.End.X); sb.Append(' '); sb.Append(geom.End.Y); sb.Append(')'); return(sb.ToString()); } return(string.Empty); }
public static double DistancePerpendicular(LineSegment2 <double> seg, Point2 <double> q) { return(DistancePerpendicular(seg.Start, seg.End, q)); }