예제 #1
0
 public static int OrientationIndex(Coordinate2 <double> p1, Coordinate2 <double> p2, Coordinate2 <double> q)
 {
     // travelling along p1->p2, turn counter clockwise to get to q return 1,
     // travelling along p1->p2, turn clockwise to get to q return -1,
     // p1, p2 and q are colinear return 0.
     //double dx1 = p2.X - p1.X;
     //double dy1 = p2.Y - p1.Y;
     //double dx2 = q.X - p2.X;
     //double dy2 = q.Y - p2.Y;
     //return AngleUtils.DeterminantSign(dx1, dy1, dx2, dy2);
     return(AngleUtils.DeterminantSign(p2.X - p1.X, p2.Y - p1.Y, q.X - p2.X, q.Y - p2.Y));
 }
예제 #2
0
        public static int OrientationIndex(double p1X, double p1Y, double p2X, double p2Y, double qX, double qY)
        {
            // travelling along p1->p2, turn counter clockwise to get to q return 1,
            // travelling along p1->p2, turn clockwise to get to q return -1,
            // p1, p2 and q are colinear return 0.
            double dx1 = p2X - p1X;
            double dy1 = p2Y - p1Y;
            double dx2 = qX - p2X;
            double dy2 = qY - p2Y;

            return(AngleUtils.DeterminantSign(dx1, dy1, dx2, dy2));
        }
예제 #3
0
        //Orientation of q with respect to line segment from p1->p2
        public static Orientation Orient(Coordinate2 <double> p1, Coordinate2 <double> p2, Coordinate2 <double> q)
        {
            double dx1  = p2.X - p1.X;
            double dy1  = p2.Y - p1.Y;
            double dx2  = q.X - p2.X;
            double dy2  = q.Y - p2.Y;
            int    sign = AngleUtils.DeterminantSign(dx1, dy1, dx2, dy2);

            if (sign < 0)
            {
                return(Orientation.Clockwise);
            }
            else if (sign > 0)
            {
                return(Orientation.Counterclockwise);
            }
            return(Orientation.Collinear);
        }
예제 #4
0
        public static Orientation Orient(double p1X, double p1Y, double p2X, double p2Y, double qX, double qY)
        {
            double dx1  = p2X - p1X;
            double dy1  = p2Y - p1Y;
            double dx2  = qX - p2X;
            double dy2  = qY - p2Y;
            int    sign = AngleUtils.DeterminantSign(dx1, dy1, dx2, dy2);

            if (sign < 0)
            {
                return(Orientation.Clockwise);
            }
            else if (sign > 0)
            {
                return(Orientation.Counterclockwise);
            }
            return(Orientation.Collinear);
        }
예제 #5
0
        //Orientation of q with respect to line segment from p1->p2
        public static Orientation Orient(Point2 <double> p1, Point2 <double> p2, Point2 <double> q)
        {
            //double dx1 = p2.X - p1.X;
            //double dy1 = p2.Y - p1.Y;
            //double dx2 = q.X - p2.X;
            //double dy2 = q.Y - p2.Y;
            //int sign = AngleUtils.DeterminantSign(dx1, dy1, dx2, dy2);
            int sign = AngleUtils.DeterminantSign(p2.X - p1.X, p2.Y - p1.Y, q.X - p2.X, q.Y - p2.Y);

            if (sign < 0)
            {
                return(Orientation.Clockwise);
            }
            else if (sign > 0)
            {
                return(Orientation.Counterclockwise);
            }
            return(Orientation.Collinear);
        }