Ejemplo n.º 1
0
 /// <summary>
 /// The coordinate pairs match if they define line segments lying in the same direction.
 /// E.g. the segments are parallel and in the same quadrant
 /// (as opposed to parallel and opposite!).
 /// </summary>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <param name="ep0"></param>
 /// <param name="ep1"></param>
 private static bool MatchInSameDirection(Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1)
 {
     if (!p0.Equals(ep0))
     {
         return(false);
     }
     return(CgAlgorithms.ComputeOrientation(p0, p1, ep1) == CgAlgorithms.COLLINEAR &&
            QuadrantOp.Quadrant(p0, p1) == QuadrantOp.Quadrant(ep0, ep1));
 }
Ejemplo n.º 2
0
 private void DoInit(Coordinate p0, Coordinate p1)
 {
     _p0       = p0;
     _p1       = p1;
     _dx       = p1.X - p0.X;
     _dy       = p1.Y - p0.Y;
     _quadrant = QuadrantOp.Quadrant(_dx, _dy);
     Assert.IsTrue(!(_dx == 0 && _dy == 0), "EdgeEnd with identical endpoints found");
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual DirectedEdge GetRightmostEdge()
        {
            IList edges = Edges;
            int   size  = edges.Count;

            if (size < 1)
            {
                return(null);
            }
            DirectedEdge de0 = (DirectedEdge)edges[0];

            if (size == 1)
            {
                return(de0);
            }
            DirectedEdge deLast = (DirectedEdge)edges[size - 1];

            int quad0 = de0.Quadrant;
            int quad1 = deLast.Quadrant;

            if (QuadrantOp.IsNorthern(quad0) && QuadrantOp.IsNorthern(quad1))
            {
                return(de0);
            }
            if (!QuadrantOp.IsNorthern(quad0) && !QuadrantOp.IsNorthern(quad1))
            {
                return(deLast);
            }
            // edges are in different hemispheres - make sure we return one that is non-horizontal
            if (de0.Dy != 0)
            {
                return(de0);
            }
            if (deLast.Dy != 0)
            {
                return(deLast);
            }
            throw new TwoHorizontalEdgesException();
        }