/// <summary> /// Creates a new instance of Segment /// </summary> public Segment(Vertex p1, Vertex p2) { P1 = p1; P2 = p2; }
/// <summary> /// Tests to see if the specified segment contains the point within Epsilon tollerance. /// </summary> /// <returns></returns> public bool IntersectsVertex(Vertex point) { double x1 = P1.X; double y1 = P1.Y; double x2 = P2.X; double y2 = P2.Y; double pX = point.X; double pY = point.Y; // COllinear if (Math.Abs((x2 - x1) * (pY - y1) - (pX - x1) * (y2 - y1)) > Epsilon) return false; // In the x is in bounds and it is colinear, it is on the segment if (x1 < x2) { if (x1 <= pX && pX <= x2) return true; } else { if (x2 <= pX && pX <= x1) return true; } return false; }
/// <summary> /// Creates a segment from double valued ordinates. /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> public Segment(double x1, double y1, double x2, double y2) { P1 = new Vertex(x1, y1); P2 = new Vertex(x2, y2); }
/// <summary> /// Gets the first vertex from the first part. /// </summary> /// <returns></returns> public Vertex First() { double[] verts = Parts[0].Vertices; Vertex result = new Vertex(verts[StartIndex], verts[StartIndex+1]); return result; }
/// <summary> /// Creates a new "point" shape that has only the one point. /// </summary> /// <param name="v"></param> public ShapeRange(Vertex v) { FeatureType = FeatureTypes.Point; Parts = new List<PartRange>(); _numParts = -1; double[] coords = new double[2]; coords[0] = v.X; coords[1] = v.Y; PartRange prt = new PartRange(coords, 0,0, FeatureTypes.Point); prt.NumVertices = 1; Parts.Add(prt); }
/// <summary> /// Creates a point from a 2D vertex. /// </summary> /// <param name="v"></param> public Point(Vertex v):this(new Coordinate(v.X, v.Y), DefaultFactory) { }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(Vertex other) { return other.X == X && other.Y == Y; }
/// <summary> /// Tests to see if the point is inside or on the boundary of this extent. /// </summary> /// <param name="vert"></param> /// <returns></returns> public bool Intersects(Vertex vert) { if (vert.X < XMin) return false; if (vert.X > XMax) return false; if (vert.Y < YMin) return false; if (vert.Y > YMax) return false; return true; }