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);
        }
        private static bool IsCubicChordMonotone(Point[] controlPoints, double squaredTolerance)
        {
            double num1 = VectorUtilities.SquaredDistance(controlPoints[0], controlPoints[3]);

            if (num1 <= squaredTolerance)
            {
                return(false);
            }
            Vector a    = controlPoints[3] - controlPoints[0];
            Vector b1   = controlPoints[1] - controlPoints[0];
            double num2 = VectorUtilities.Dot(a, b1);

            if (num2 < 0.0 || num2 > num1)
            {
                return(false);
            }
            Vector b2   = controlPoints[2] - controlPoints[0];
            double num3 = VectorUtilities.Dot(a, b2);

            return(num3 >= 0.0 && num3 <= num1 && num2 <= num3);
        }