Example #1
0
        internal bool PointInPolygon(IntPoint pt, OutPt pp, bool UseFullRange)
        {
            OutPt next = pp;
            bool  flag = false;

            if (UseFullRange)
            {
                do
                {
                    if ((next.Pt.Y > pt.Y) != (next.Prev.Pt.Y > pt.Y))
                    {
                        Int128 introduced2 = Int128.Int128Mul(next.Prev.Pt.X - next.Pt.X, pt.Y - next.Pt.Y);
                        if (new Int128(pt.X - next.Pt.X) < (introduced2 / new Int128(next.Prev.Pt.Y - next.Pt.Y)))
                        {
                            flag = !flag;
                        }
                    }
                    next = next.Next;
                }while (next != pp);
                return(flag);
            }
            do
            {
                if (((next.Pt.Y > pt.Y) != (next.Prev.Pt.Y > pt.Y)) && ((pt.X - next.Pt.X) < (((next.Prev.Pt.X - next.Pt.X) * (pt.Y - next.Pt.Y)) / (next.Prev.Pt.Y - next.Pt.Y))))
                {
                    flag = !flag;
                }
                next = next.Next;
            }while (next != pp);
            return(flag);
        }
Example #2
0
 protected static bool SlopesEqual(IntPoint pt1, IntPoint pt2, IntPoint pt3, bool UseFullRange)
 {
     if (UseFullRange)
     {
         return(Int128.Int128Mul(pt1.Y - pt2.Y, pt2.X - pt3.X) == Int128.Int128Mul(pt1.X - pt2.X, pt2.Y - pt3.Y));
     }
     return((((pt1.Y - pt2.Y) * (pt2.X - pt3.X)) - ((pt1.X - pt2.X) * (pt2.Y - pt3.Y))) == 0L);
 }
Example #3
0
 internal static bool SlopesEqual(TEdge e1, TEdge e2, bool UseFullRange)
 {
     if (UseFullRange)
     {
         return(Int128.Int128Mul(e1.Delta.Y, e2.Delta.X) == Int128.Int128Mul(e1.Delta.X, e2.Delta.Y));
     }
     return(e1.Delta.Y * e2.Delta.X == e1.Delta.X * e2.Delta.Y);
 }
Example #4
0
 internal static bool SlopesEqual(TEdge e1, TEdge e2, bool UseFullRange)
 {
     if (UseFullRange)
     {
         Int128 introduced0 = Int128.Int128Mul(e1.Delta.Y, e2.Delta.X);
         return(introduced0 == Int128.Int128Mul(e1.Delta.X, e2.Delta.Y));
     }
     return((e1.Delta.Y * e2.Delta.X) == (e1.Delta.X * e2.Delta.Y));
 }
Example #5
0
 internal bool PointOnLineSegment(IntPoint pt, IntPoint linePt1, IntPoint linePt2, bool UseFullRange)
 {
     if (UseFullRange)
     {
         return((((pt.X == linePt1.X) && (pt.Y == linePt1.Y)) || ((pt.X == linePt2.X) && (pt.Y == linePt2.Y))) || ((((pt.X > linePt1.X) == (pt.X < linePt2.X)) && ((pt.Y > linePt1.Y) == (pt.Y < linePt2.Y))) && (Int128.Int128Mul(pt.X - linePt1.X, linePt2.Y - linePt1.Y) == Int128.Int128Mul(linePt2.X - linePt1.X, pt.Y - linePt1.Y))));
     }
     return((((pt.X == linePt1.X) && (pt.Y == linePt1.Y)) || ((pt.X == linePt2.X) && (pt.Y == linePt2.Y))) || ((((pt.X > linePt1.X) == (pt.X < linePt2.X)) && ((pt.Y > linePt1.Y) == (pt.Y < linePt2.Y))) && (((pt.X - linePt1.X) * (linePt2.Y - linePt1.Y)) == ((linePt2.X - linePt1.X) * (pt.Y - linePt1.Y)))));
 }
Example #6
0
        internal bool PointInPolygon(IntPoint pt, OutPt pp, bool UseFullRange)
        {
            OutPt outPt = pp;
            bool  flag  = false;

            if (UseFullRange)
            {
                do
                {
                    if (outPt.Pt.Y > pt.Y != outPt.Prev.Pt.Y > pt.Y && new Int128(pt.X - outPt.Pt.X) < Int128.Int128Mul(outPt.Prev.Pt.X - outPt.Pt.X, pt.Y - outPt.Pt.Y) / new Int128(outPt.Prev.Pt.Y - outPt.Pt.Y))
                    {
                        flag = !flag;
                    }
                    outPt = outPt.Next;
                }while (outPt != pp);
            }
            else
            {
                do
                {
                    if (outPt.Pt.Y > pt.Y != outPt.Prev.Pt.Y > pt.Y && pt.X - outPt.Pt.X < (outPt.Prev.Pt.X - outPt.Pt.X) * (pt.Y - outPt.Pt.Y) / (outPt.Prev.Pt.Y - outPt.Pt.Y))
                    {
                        flag = !flag;
                    }
                    outPt = outPt.Next;
                }while (outPt != pp);
            }
            return(flag);
        }