DIRECTORY Complex, Cubic, Seq; LSPiece: CEDAR DEFINITIONS = BEGIN OPEN Seq; FitPiece: PROCEDURE [z: ComplexSequence, t: RealSequence _ NIL, from, thru: NAT, -- fit points in range [from..thru] modulo z.length eps: REAL _ .00001, -- stop iterating if the sum of squares gets below this amount maxd: REAL _ .00001, --stop iterating if the maximum deviation gets below this amount maxit: NAT _ 500, -- limit on number of iterations deltat: REAL _ 0.000005, -- stop when the t values each change by less than this initFree, finalFree: BOOLEAN _ FALSE, initTangent, finalTangent: Complex.Vec _ [0,0], useOldTValues: BOOLEAN _ FALSE] RETURNS [b: Cubic.Bezier, err: REAL, iterations: NAT, maxDev: REAL]; END. ´LSPiece.mesa For fitting a single cubic piece with specified endpoints, and possibly specified tangents. Maureen Stone July 17, 1982 4:07 pm Michael Plass 28-Jan-82 12:14:59 FitPiece will fit a cubic patch to the points z[from], z[(from+1) MOD l],..., z[thru], where l=z.length. The curve will pass through the points z[from] (if initFree) and z[thru] (if finalFree), and the tangents at the endpoints will be parallel to initTangent and finalTangent, if these are specified to be non-zero. The sum of the squares of the distances from the points to the curve are returned in err, and the largest deviation is returned in maxDev. The values of t[from] thru t[thru] will be set to the parameters of these closest points, with t[from]=0 and t[thru]=1. The iteration is stopped when either (1) err <= eps, (2) err has increased over the previous iteration, (3) the largest change in a t value is less than deltat, or (4) iterations >= maxit. ʘJšœ ™ Jšœ[™[Jšœ#™#Jšœ ™ J˜šÏk ˜ J˜J˜J˜J˜—Jšœ œ œ˜Jšœœ˜J˜šÏnœ ˜Jšœ'œ˜+Jšœ œÏc3˜DJšœœ Ÿ>˜Ršœœ Ÿ@˜VJšœœŸ ˜2Jšœœ Ÿ7˜PJšœœœ˜%J˜/Jšœœœ˜Jšœœœ œ˜DJšœÿ™ÿJ˜——Jšœ˜—…—ÄŠ