public static void FlattenQuadratic(Point[] controlPoints, double errorTolerance, List <Point> resultPolyline, bool connect) { BezierCurveFlattener.FlattenCubic(new Point[4] { controlPoints[0], VectorUtilities.WeightedAverage(controlPoints[0], controlPoints[1], 2.0 / 3.0), VectorUtilities.WeightedAverage(controlPoints[1], controlPoints[2], 1.0 / 3.0), controlPoints[2] }, errorTolerance, resultPolyline, connect); }
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); }