LSSplineCmds.mesa
LSSplineJaM.mesa
last edited by Michael Plass August 12, 1982 1:22 pm
last edited by Maureen Stone May 15, 1984 3:21:34 pm PDT
DIRECTORY
Cubic,
Complex,
LSSpline,
Curve,
JaM,
FitJaM USING [RegisterInit, InitProc],
Seq;
LSSplineJaM: CEDAR PROGRAM IMPORTS Complex, LSSpline, Curve, JaM, FitJaM =
BEGIN
lsSpline: LSSpline.Handle ← LSSpline.Create[];
Subdivide: PROC [state: JaM.State] = {
tolerance: REAL ← JaM.PopReal[state];
cubicProc: PROC[b: Cubic.Bezier] = {Curve.AddLink[Curve.defaultHandle, b]};
currentSamples: Seq.ComplexSequence ← Curve.CurrentSamples[Curve.defaultHandle];
closed: BOOLEAN ← (currentSamples[0] = currentSamples[currentSamples.length-1]);
lsSpline.Reset[];
Curve.ResetLinks[Curve.defaultHandle];
FOR i: NAT IN [0..currentSamples.length) DO
tangent: Complex.Vec ← [0,0];
IF i IN (0..currentSamples.length-1) THEN
tangent ← Complex.Sub[currentSamples[i+1], currentSamples[i-1]]
ELSE IF closed THEN tangent ←
Complex.Sub[currentSamples[1], currentSamples[currentSamples.length-2]];
lsSpline.Sample[currentSamples[i], tangent];
ENDLOOP;
lsSpline.Subdivide[cubicProc, tolerance];
};
Init: FitJaM.InitProc = {
JaM.Register[state,".subdividespline", Subdivide];
};
FitJaM.RegisterInit[$LSSplineCmds,Init];
END.
Michael Plass August 12, 1982 1:22 pm. Fixed tangent calculation for closed samples.