Пример #1
0
        internal static bool ArePolylinesClose(List <Point> p, double[] lengthP, int firstP, int lastP, List <Point> q, double[] lengthQ, int firstQ, int lastQ, double distanceTolerance, ref int firstBadVertexInQ)
        {
            double num1   = distanceTolerance * distanceTolerance;
            int    index1 = firstP;
            double num2   = lengthP[firstP];
            double num3   = lengthQ[firstQ];

            for (int index2 = firstQ + 1; index2 < lastQ; ++index2)
            {
                while (index1 <= lastP && lengthQ[index2] - num3 > lengthP[index1] - num2)
                {
                    ++index1;
                }
                if (index1 > lastP)
                {
                    for (int index3 = index2; index3 < lastQ; ++index3)
                    {
                        if (VectorUtilities.SquaredDistance(p[lastP], q[index3]) > num1)
                        {
                            firstBadVertexInQ = index3;
                            return(false);
                        }
                    }
                    return(true);
                }
                Vector vector = (p[index1] - p[index1 - 1]) * ((lengthQ[index2] - num3 - lengthP[index1 - 1] + num2) / (lengthP[index1] - lengthP[index1 - 1]));
                if (VectorUtilities.SquaredDistance(p[index1 - 1] + vector, q[index2]) > num1)
                {
                    firstBadVertexInQ = index2;
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
        public static double[] GetCumulatedChordLength(List <Point> points, int firstIndex, int lastIndex)
        {
            if (firstIndex <= lastIndex && firstIndex >= 0 && (lastIndex >= 0 && firstIndex < points.Count))
            {
                int count = points.Count;
            }
            double[] numArray = new double[lastIndex - firstIndex + 1];
            double   num      = 0.0;

            numArray[0] = num;
            int index1 = firstIndex + 1;
            int index2 = 1;

            while (index1 <= lastIndex)
            {
                num += VectorUtilities.Distance(points[index1 - 1], points[index1]);
                numArray[index2] = num;
                ++index1;
                ++index2;
            }
            return(numArray);
        }
Пример #3
0
        public static bool ComputeClosestPointOnTransformedLineSegment(Point point, Point a, Point b, Matrix matrix, double toleranceSquared, out double resultParameter, out Point resultPoint, out double resultDistanceSquared)
        {
            Vector a1            = (b - a) * matrix;
            Vector b1            = point - a * matrix;
            double lengthSquared = a1.LengthSquared;

            resultParameter = lengthSquared < FloatingPointArithmetic.SquaredDistanceTolerance ? 0.0 : VectorUtilities.Dot(a1, b1) / lengthSquared;
            if (resultParameter <= 0.0)
            {
                resultParameter = 0.0;
                resultPoint     = a;
            }
            else if (resultParameter >= 1.0)
            {
                resultParameter = 1.0;
                resultPoint     = b;
            }
            else
            {
                resultPoint = VectorUtilities.WeightedAverage(a, b, resultParameter);
            }
            resultDistanceSquared = (resultPoint * matrix - point).LengthSquared;
            return(resultDistanceSquared <= toleranceSquared);
        }
Пример #4
0
 public static bool ComputeClosestPointOnLineSegment(Point point, Point a, Point b, double toleranceSquared, out double resultParameter, out Point resultPoint, out double resultDistanceSquared)
 {
     return(VectorUtilities.ComputeClosestPointOnTransformedLineSegment(point, a, b, Matrix.Identity, toleranceSquared, out resultParameter, out resultPoint, out resultDistanceSquared));
 }
Пример #5
0
 internal static Vector GetInvertZoomFactor(DesignerView dview)
 {
     return(VectorUtilities.InvertScale(TransformUtil.GetScaleFromTransform(dview.GetZoomTransform())));
 }