DIRECTORY Complex USING [VEC], Cubic2 USING [Bezier], Seq USING [ComplexSequence, RealSequence]; LSPiece: CEDAR DEFINITIONS = BEGIN OPEN Seq; Metrics: TYPE = REF MetricsRec; MetricsRec: TYPE = RECORD [ maxItr: INT ¬ 10, -- limit on number of iterations maxDev: REAL ¬ .00001, --stop iterating if the maximum deviation gets below this amount sumErr: REAL ¬ .00001, -- stop iterating if the sum of squares gets below this amount deltaT: REAL ¬ 0.000005 -- stop when the t values each change by less than this ]; FitPiece: PROCEDURE [ z: ComplexSequence, t: RealSequence ¬ NIL, metrics: Metrics, from, thru: NAT, -- fit points in range [from..thru] modulo z.length initFree, finalFree: BOOLEAN ¬ FALSE, initTangent, finalTangent: Complex.VEC ¬ [0,0], useOldTValues: BOOLEAN ¬ FALSE] RETURNS [b: Cubic2.Bezier, err: REAL, iterations: INT, maxDev: REAL, indexOfMaxDev: NAT]; RealSample: TYPE = REF RealSampleObj; RealSampleObj: TYPE = RECORD [real: SEQUENCE len: NAT OF BOOLEAN]; FitPiece2: PROC [ z: ComplexSequence, t: RealSequence ¬ NIL, metrics: Metrics, from, thru: NAT, -- fit points in range [from..thru] modulo z.length initFree, finalFree: BOOL ¬ FALSE, initTangent, finalTangent: Complex.VEC ¬ [0,0], useOldTValues: BOOL ¬ FALSE, someInterp: BOOL ¬ FALSE, realSample: RealSample ¬ NIL] RETURNS [b: Cubic2.Bezier, err: REAL, iterations: INT, maxDev: REAL, indexOfMaxDev: NAT]; ComputeCurvature: PROC [farCP, nearCP, joint: Complex.VEC, jointFirst: BOOL] RETURNS [REAL]; CurvatureAtPt: PROC [bezier: Cubic2.Bezier, pt: Complex.VEC] RETURNS [REAL]; END. ®LSPiece.mesa Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved. Maureen Stone August 29, 1984 5:33:42 pm PDT Michael Plass 28-Jan-82 12:14:59 Doug Wyatt, September 5, 1985 1:13:09 pm PDT Maureen Stone, September 23, 1987 12:54:48 pm PDT For fitting a single cubic piece with specified endpoints, and possibly specified tangents. FitPiece will fit a cubic patch to the points z[from], z[(from+1) MOD l],..., z[thru], where l=z.length. The curve will pass through the points z[from] (if initFree) and z[thru] (if finalFree), and the tangents at the endpoints will be parallel to initTangent and finalTangent, if these are specified to be non-zero. The sum of the squares of the distances from the points to the curve are returned in err, and the largest deviation is returned in maxDev. The values of t[from] thru t[thru] will be set to the parameters of these closest points, with t[from]=0 and t[thru]=1. The iteration is stopped when either (1) err <= eps, (2) err has increased over the previous iteration, (3) the largest change in a t value is less than deltat, or (4) iterations >= maxit. Like LSPiece.FitPiece, but with extra arguments someInterp amd realSample. ʾ•NewlineDelimiter –(cedarcode) style˜codešœ ™ Kšœ Ïeœ6™BKšœ,™,Kšœ ™ K™,K™1—K˜Kšœ[™[K™šÏk ˜ Kšœžœžœ˜Kšœžœ ˜Kšœžœ!˜*—K˜KšÐblœžœž œ˜Kšžœžœ˜˜Kšœ žœžœ ˜šœ žœžœ˜KšœžœžœÏc ˜2Kšœžœžœ @˜WKšœžœ  >˜UKšœžœ  7˜OK˜—K˜šÏnœž œ˜Kšœ&žœ˜*Kšœ˜Kšœ žœ 3˜DKšœžœžœ˜%Kšœ#žœ ˜/Kšœžœžœ˜Kš žœžœžœ žœžœ˜YK™Kšœÿ™ÿK™—Kšœ žœžœ˜%šœžœžœœžœžœžœžœ˜BK˜—š¡ œžœ˜Kšœ&žœ˜*Kšœ˜Kšœ žœ 3˜DKšœžœžœ˜"Kšœ#žœ ˜/Kšœžœž˜Kšœ žœžœ˜Kšœžœ˜Kš žœžœžœ žœžœ˜YšœJ™JK˜——š ¡œžœ žœžœžœžœ˜\K˜—š ¡ œžœ%žœžœžœ˜LK˜——Kšžœ˜—…— Š