DIRECTORY Complex USING [VEC], Cubic USING [Bezier], LSFit USING [Patch, PatchSequence, PatchSequenceRec], PiecewiseCubic USING [Handle], Seq USING [BooleanSequence, ComplexSequence, RealSequence]; LSCurve: CEDAR DEFINITIONS = BEGIN OPEN Seq; Patch: TYPE = LSFit.Patch; PatchSequence: TYPE = LSFit.PatchSequence; PatchSequenceRec: TYPE = LSFit.PatchSequenceRec; Handle: TYPE = REF StateRec; StateRec: TYPE = RECORD [z: ComplexSequence, -- the points to fit weight: RealSequence, -- weights for each point t: RealSequence, -- the current best guess of parameter values. Always between 0 and 1. oldt,oldoldt: RealSequence, -- for convergence acceleration l,n: NAT, -- use just the points in the range [l..n] splineBasis: SplineBasis, -- the current basis functions a: RealSequence, -- the coefficients on the basis funtions for the current fit free: BooleanSequence, -- tells which coefficients may be varied closedCurve: BOOLEAN, initialEndFree, finalEndFree: BOOLEAN, -- tells how to rescale patchCacheValid: BOOLEAN _ FALSE, patchCache: SplineFunction ]; SplineBasis: TYPE = REF SplineBasisRec; SplineBasisRec: TYPE = RECORD[SEQUENCE nBasis: NAT OF SplineFunction]; SplineFunction: TYPE = RECORD [x, y: PiecewiseCubic.Handle]; Create: PROCEDURE [sa: Seq.ComplexSequence] RETURNS [Handle]; XYat: PROCEDURE [h: Handle, t: REAL] RETURNS [Complex.VEC]; PatchesOf: PROCEDURE [h: Handle] RETURNS [x, y: PatchSequence, knots: RealSequence]; ArcLengthInitialTValues: PUBLIC PROCEDURE [h: Handle]; -- sets t values on the basis of arc length UnitInitialTValues: PUBLIC PROCEDURE [h: Handle]; -- sets t values on equal steps AngleInitialTValues: PUBLIC PROCEDURE [h: Handle]; AdjustTValues: PUBLIC PROCEDURE [h: Handle] RETURNS [maxChange: REAL]; -- uses 1 step of Newton's method AccelTValues: PUBLIC PROCEDURE [h: Handle] RETURNS [r, maxChange: REAL]; -- applies convergence acceleration - assume SolveCurve has just been done SolveTValues: PUBLIC PROCEDURE [h: Handle]; -- really sets the t values, assuming no old ones are known, but that the curve is known SolveCurve: PUBLIC PROCEDURE [h: Handle]; -- finds the best fit, assuming the t values are known. Only the free coefficients are altered. PointSlopeBasis: PUBLIC PROCEDURE [h: Handle, b: Cubic.Bezier]; SmoothBasis: PUBLIC PROCEDURE [h: Handle, nKnots: NAT]; BSplineBasis: PUBLIC PROCEDURE [h: Handle, nKnots: NAT]; CubicBasis: PUBLIC PROCEDURE [h: Handle]; CubicPieceBasis: PUBLIC PROCEDURE [h: Handle]; ParabolaBasis: PUBLIC PROCEDURE [h: Handle]; CircleBasis: PUBLIC PROCEDURE [h: Handle]; EllipseBasis: PUBLIC PROCEDURE [h: Handle]; END. ΘLSCurve.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Michael Plass November 29, 1982 9:52 am Doug Wyatt, September 5, 1985 1:16:58 pm PDT implementor private stuff follows ΚX˜codešœ ™ Kšœ Οmœ1™Kšœ!™!Kšœžœžœ˜!K˜K˜——K˜Kšœ žœžœ˜'šœžœ˜Kšžœžœ žœžœ˜/—K˜Kšœžœžœ˜^