示例#1
0
        public static bool IsPointInLine(Point <double> l1, Point <double> l2, Point <double> p)
        {
            if (PointHelper.OrientationOfThreePoints(l1, l2, p) == 0 && p.X >= Math.Min(l1.X, l2.X) && p.X <= Math.Max(l1.X, l2.X) && p.Y >= Math.Min(l1.Y, l2.Y) && p.Y <= Math.Max(l1.Y, l2.Y))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public static bool IsTwoLineIntersect(Point <double> p1, Point <double> p2, Point <double> q1, Point <double> q2)
        {
            if ((PointHelper.OrientationOfThreePoints(p1, p2, q1) != PointHelper.OrientationOfThreePoints(p1, p2, q2)) && (PointHelper.OrientationOfThreePoints(q1, q2, p1) != PointHelper.OrientationOfThreePoints(q1, q2, p2)))
            {
                return(true);
            }

            var rangeX1 = new Range <double>(p1.X, p2.X);
            var rangeX2 = new Range <double>(q1.X, q2.X);
            var rangeY1 = new Range <double>(p1.Y, p2.Y);
            var rangeY2 = new Range <double>(q1.Y, q2.Y);

            if (PointHelper.OrientationOfThreePoints(p1, p2, q1) == 0 && PointHelper.OrientationOfThreePoints(p1, p2, q2) == 0 && RangeHeper.IsIntersect(rangeX1, rangeX2) && RangeHeper.IsIntersect(rangeY1, rangeY2))
            {
                return(true);
            }

            return(false);
        }