-- LSSplineCmds.mesa --last edited by Michael Plass August 12, 1982 1:22 pm DIRECTORY Cubic, Complex, LSSpline, Curve, JaMFnsDefs, Seq; LSSplineCmds: PROGRAM IMPORTS Complex, LSSpline, Curve, JaMFnsDefs = BEGIN lsSpline: LSSpline.Handle ← LSSpline.Create[]; Subdivide: PROC = { tolerance: REAL ← JaMFnsDefs.GetReal[]; 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]; }; JaMFnsDefs.Register[".subdividespline", Subdivide]; END. Michael Plass August 12, 1982 1:22 pm. Fixed tangent calculation for closed samples.