CubicPathsExtras.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on December 1, 1986 4:42:55 pm PST
Contents: A new set of routines for operating on two-dimensional cubics. ClosestPointAnalytic is usually several times faster than CubicPaths.ClosestPoint, because it only searches for roots in the interval [0..1].
DIRECTORY
Cubic2, CubicPaths, Polynomial, Vector2;
CubicPathsExtras: CEDAR DEFINITIONS =
BEGIN
Bezier: TYPE = Cubic2.Bezier;
BezierRef: TYPE = REF Bezier;
Path: TYPE = CubicPaths.Path;
ShortRealRootRec: TYPE = Polynomial.ShortRealRootRec;
VEC: TYPE = Vector2.VEC;
ClosestPointAnalytic:
PROC[pt:
VEC, path: Path, tolerance:
REAL ← 9999.0]
RETURNS [closest:
VEC, success:
BOOL];
Faster than ClosestPointSubdivide, more accurate, and almost as robust. If success = TRUE, the point returned is guaranteed to be quite close to the Bezier path. The point is quite close because it results from plugging in a value of the parameter. The point returned is also quite close to the actual closest point, since the parameter chosen is within a floating point round-off error of being a root of the "closest point" polynomials. IF success = FALSE, no point on path is within tolerance of pt. In this case, closest is not valid data.
GetParam:
PROC [bezier: Bezier, pt:
VEC]
RETURNS [u:
REAL];
Given a bezier curve, and a point on the curve, find the parameter value u that generates pt.
CubicMeetsLine:
PROC [bezier: Bezier, a, b, c:
REAL]
RETURNS [points:
ARRAY [0..2]
OF
VEC, hitCount: [0..3], tangency:
ARRAY [0..2]
OF
BOOL];
Find the intersection points of the Bezier cubic piece bezier and the line:
ax + by + c = 0.
END.