Esempio n. 1
0
 internal PointSet2(LineSegment2 <T> item)
 {
     if (item == null)
     {
         throw new ArgumentNullException();
     }
     this.Points = new Point2 <T>[] { item.Start, item.End };
 }
Esempio n. 2
0
 public bool Equals(LineSegment2 <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.Start.Equals(other.Start) && this.End.Equals(other.End));
 }
Esempio n. 3
0
 public static double Length(LineSegment2 <double> seg)
 {
     if (seg == null)
     {
         return(double.NaN);
     }
     return(Length(seg.Start, seg.End));
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 public LineSegment2(LineSegment2 <T> other)
 {
     if (other == null)
     {
         throw new ArgumentNullException();
     }
     this.Start = other.Start;
     this.End   = other.End;
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
        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
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 public static double DistancePerpendicular(LineSegment2 <double> seg, Point2 <double> q)
 {
     return(DistancePerpendicular(seg.Start, seg.End, q));
 }