<<>> <> <> <> <> <> <> <> <<>> DIRECTORY Seq USING [ComplexSequence, JointSequence, RealSequence], Complex USING [VEC], Rope USING [ROPE], LSPiece USING [Metrics], Cubic2 USING [Bezier]; PiecewiseFit: CEDAR DEFINITIONS = { Data: TYPE = REF DataRec; DataRec: TYPE = RECORD [ samples: Seq.ComplexSequence, closed: BOOLEAN, joints: Seq.JointSequence, --[index: NAT, forced: BOOLEAN] tangents: Seq.ComplexSequence --two per potentialKnot; tanIn, tanOut ]; <> <> <> Default: PROC [data: Data]; <> << >> Error: SIGNAL [why: Rope.ROPE]; <<>> Metrics: TYPE = LSPiece.Metrics; <> <> <> <> <> <> <<];>> <= maxItr. The curve is not guaranteed to fit within all the metrics, only the first one to get small enough.>> Cubic2Proc: TYPE = PROC[bezier: Cubic2.Bezier, sumErr, maxDev: REAL, iterations: INT] RETURNS[quit: BOOLEAN ¬ FALSE]; <> FitSpline: PROC [data: Data, metrics: Metrics, outputCubic2: Cubic2Proc]; <> GrowSpline: PROC [data: Data, metrics: Metrics, outputCubic2: Cubic2Proc, hilight: Cubic2Proc ¬ NIL]; <> DynSpline: PROC [data: Data, metrics: Metrics, penalty: REAL, trim: BOOLEAN ¬ TRUE, outputCubic2: Cubic2Proc, hilight: Cubic2Proc ¬ NIL]; <> FitPiece: PROC [data: Data, from, thru: NAT, initFree, finalFree: BOOLEAN ¬ TRUE, metrics: Metrics, outputCubic2: Cubic2Proc]; <> TangentProc: TYPE = PROC[data: Data, at: NAT] RETURNS[Complex.VEC]; --at is the index of the point where the tangent is needed ie. data.samples[at]; AdaptiveFit: PROC [data: Data, from, thru: NAT, initFree, finalFree: BOOLEAN ¬ TRUE, metrics: Metrics, outputCubic2: Cubic2Proc, tangent: TangentProc]; <> JointTanRec: TYPE = RECORD[index: NAT, tanIn, tanOut: Complex.VEC ¬ [0,0]]; JointTanSeqRec: TYPE = RECORD[element: SEQUENCE length:NAT OF JointTanRec]; JointTanSequence: TYPE = REF JointTanSeqRec; GrowSpline2: PROC [data: Data, realLength: NAT, metrics: Metrics, outputCubic2: Cubic2Proc, tangent: TangentProc, debug: BOOL ¬ FALSE, hilight: Cubic2Proc ¬ NIL]; <> DynSpline2: PUBLIC PROC [data: Data, realLength: NAT, metrics: Metrics, penalty: REAL, trim: BOOL ¬ TRUE, outputCubic2: Cubic2Proc, tangent: TangentProc, debug: BOOL ¬ FALSE, hilight: Cubic2Proc ¬ NIL]; <> AdaptiveFit2: PROC [data: Data, from, thru: NAT, initFree, finalFree: BOOL ¬ TRUE, metrics: Metrics, outputCubic2: Cubic2Proc, tangent: TangentProc, debug: BOOL ¬ FALSE, hilight: Cubic2Proc]; <> IterFit: PROC [data: Data, from, thru: NAT, initFree, finalFree: BOOL ¬ TRUE, metrics: Metrics, outputCubic2: Cubic2Proc, tangent: TangentProc, debug: BOOL ¬ FALSE, hilight: Cubic2Proc ¬ NIL, earlyBreak: BOOL ¬ TRUE, useMaxDev: BOOL ¬ TRUE, joints: JointTanSequence ¬ NIL]; ChunkGrow: PUBLIC PROC [data: Data, realLength: NAT, metrics: Metrics, outputCubic2: Cubic2Proc, tangent: TangentProc, debug: BOOL ¬ FALSE, hilight: Cubic2Proc ¬ NIL]; <> FitPieceInterp2: PROC [z: Seq.ComplexSequence, t: Seq.RealSequence ¬ NIL, from, thru: NAT, metrics: Metrics, initFree, finalFree: BOOL ¬ FALSE, initTangent, finalTangent: Complex.VEC ¬ [0,0], useOldTValues: BOOL ¬ FALSE] RETURNS [b: Cubic2.Bezier, err: REAL, iterations: NAT, maxDev: REAL, indexOfMaxDev: NAT]; <> }.