-- LSSpline.mesa
-- For fitting a cubic spline with specified endpoints and  tangents.
-- Michael Plass  August 3, 1982 3:47 pm

DIRECTORY
  Complex,
  Cubic,
  Seq;

LSSpline: DEFINITIONS =
BEGIN

Handle: PUBLIC TYPE = REF Rec;
Rec: PUBLIC TYPE = RECORD [
	z: Seq.ComplexSequence ← NIL,
	tan: Seq.ComplexSequence ← NIL,
	t: Seq.RealSequence ← NIL,
	length: NAT ← 0
	];
	-- Non-opaque for Warnock's sake. 

Create: PUBLIC PROCEDURE [lengthHint: NAT ← 10]
	RETURNS [handle: Handle];

Reset: PUBLIC PROCEDURE [handle: Handle];

Sample: PUBLIC PROCEDURE [
	handle: Handle,
	samplePoint: Complex.Vec,
	tangent: Complex.Vec ← [0,0]];
	-- Will expand the data structures if necessary.

CubicProc: TYPE = PROCEDURE [Cubic.Bezier];

Subdivide: PUBLIC PROCEDURE [
	handle: Handle,
	cubicProc: CubicProc,
	tolerance: REAL,
	from: NAT ← 0,
	thru: NAT ← LAST[NAT]
	];

END.