SampledCurves.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Maureen Stone May 25, 1985 3:50:13 pm PDT
Doug Wyatt, September 5, 1985 2:39:06 pm PDT
DIRECTORY
Vector USING [VEC],
Seq USING [ComplexSequence, RealSequence];
SampledCurves: CEDAR DEFINITIONS = {
SampledCurve: TYPE = REF SampledCurveRec;
PointRec: TYPE = RECORD [p, t: Vector.VEC, k,ds: REAL];
SampledCurveRec: TYPE = RECORD[closed: BOOLEAN, element: SEQUENCE length:NAT OF PointRec];
SampledCurveFromSamples: PROC [samples: Seq.ComplexSequence, closed: BOOLEAN] RETURNS[SampledCurve];
DeltaK: PROC[sc: SampledCurve] RETURNS [deltas: Seq.RealSequence];
Wrap takes an index and returns the newIndex MOD curve length if the curve is closed, does the end test and raises OpenCurve if the curve is open.
Wrap: PROC[sc: SampledCurve, index: INT] RETURNS [newIndex: NAT];
OpenCurve: SIGNAL; --raised when you try an illegal operation on an open curve
ArcLength: PROC[sc: SampledCurve, from, to: NAT] RETURNS[d: REAL];
This finds a sequence of TRUE values as defined by the ConditionProc.
ft is the index of the first TRUE value, lt is the index of the last TRUE value
Uses unwrapped values ie. start, ft, lt can be outside the range [0..bool.length)
ConditionProc: TYPE = PROC[point: PointRec] RETURNS[BOOLEAN];
None: SIGNAL;
FindSequence: PROC[sc: SampledCurve, start: NAT, condition: ConditionProc] RETURNS[ft, lt: NAT];
Some procedures for computing curvature.
There are two methods:
(the change in angle)/(change in arc length)
approximated by ArcTan[Cross[dIn, dOut],Dot[dIn, dOut]]
Find the radius of the center of the circle that contains the three points (0,0) dIn, dOut
CurvatureProc: TYPE = PROC[dIn,dOut: Vector.VEC] RETURNS [REAL];
SetKProc: PROC[CurvatureProc];
DThetaDegrees: CurvatureProc;
DThetaRadians: CurvatureProc;
CircleCenter: CurvatureProc;
FindCircleCenter: PROC[p0,p1,p2: Vector.VEC] RETURNS [center: Vector.VEC, valid: BOOLEAN];
Finds the center of the circle defined by the three points. Not valid if the points are colinear or nearly so.
FindAngleDegrees: PROC[dIn,dOut: Vector.VEC] RETURNS [REAL];
The change in direction from dIn to dOut.
}.