TriangleNet.Primitives.CounterClockwise C# (CSharp) Method

CounterClockwise() public static method

Check, if the three points appear in counterclockwise order. The result is also a rough approximation of twice the signed area of the triangle defined by the three points.
Uses exact arithmetic if necessary to ensure a correct answer. The result returned is the determinant of a matrix. This determinant is computed adaptively, in the sense that exact arithmetic is used only to the degree it is needed to ensure that the returned value has the correct sign. Hence, this function is usually quite fast, but will run more slowly when the input points are collinear or nearly so. See Robust Predicates paper for details.
public static CounterClockwise ( System.Point pa, System.Point pb, System.Point pc ) : double
pa System.Point Point a.
pb System.Point Point b.
pc System.Point Point c.
return double
        public static double CounterClockwise(Point pa, Point pb, Point pc)
        {
            double detleft, detright, det;
            double detsum, errbound;

            Statistic.CounterClockwiseCount++;

            detleft = (pa.x - pc.x) * (pb.y - pc.y);
            detright = (pa.y - pc.y) * (pb.x - pc.x);
            det = detleft - detright;

            if (Behavior.NoExact)
            {
                return det;
            }

            if (detleft > 0.0)
            {
                if (detright <= 0.0)
                {
                    return det;
                }
                else
                {
                    detsum = detleft + detright;
                }
            }
            else if (detleft < 0.0)
            {
                if (detright >= 0.0)
                {
                    return det;
                }
                else
                {
                    detsum = -detleft - detright;
                }
            }
            else
            {
                return det;
            }

            errbound = ccwerrboundA * detsum;
            if ((det >= errbound) || (-det >= errbound))
            {
                return det;
            }

            return (double)CounterClockwiseDecimal(pa, pb, pc);
        }

Usage Example

Ejemplo n.º 1
0
        public static Point FindCircumcenter(Point torg, Point tdest, Point tapex, ref double xi, ref double eta)
        {
            double num;

            Statistic.CircumcenterCount = Statistic.CircumcenterCount + (long)1;
            double num1 = tdest.x - torg.x;
            double num2 = tdest.y - torg.y;
            double num3 = tapex.x - torg.x;
            double num4 = tapex.y - torg.y;
            double num5 = num1 * num1 + num2 * num2;
            double num6 = num3 * num3 + num4 * num4;

            if (!Behavior.NoExact)
            {
                num = 0.5 / Primitives.CounterClockwise(tdest, tapex, torg);
                Statistic.CounterClockwiseCount = Statistic.CounterClockwiseCount - (long)1;
            }
            else
            {
                num = 0.5 / (num1 * num4 - num3 * num2);
            }
            double num7 = (num4 * num5 - num2 * num6) * num;
            double num8 = (num1 * num6 - num3 * num5) * num;

            xi  = (num4 * num7 - num3 * num8) * (2 * num);
            eta = (num1 * num8 - num2 * num7) * (2 * num);
            return(new Point(torg.x + num7, torg.y + num8));
        }
All Usage Examples Of TriangleNet.Primitives::CounterClockwise