INTERFACE PZGeo3; (* Miscellaneous geometry tools *) (* Last edited on 1999-08-06 22:03:36 by hcgl *) IMPORT LR3; TYPE Point = LR3.T; LONG = LONGREAL; PROCEDURE LinearInterpolate( t: LONG; a: LONG; READONLY pa: Point; b: LONG; READONLY pb: Point; ): Point; (* Interpolates linearly the position at time "t" between points "pa" and "b", assuming they have times "a" and "b". *) PROCEDURE HermiteInterpolate( t: LONG; a: LONG; READONLY pa: Point; READONLY va: Point; b: LONG; READONLY pb: Point; READONLY vb: Point; VAR p: Point; VAR v: Point; ); (* Performs cubic Hermite interpolation for argument "t" given positions "pa" and "pb" and velocities "va" and "vb" at times "a" and "b". Best used for "t" between "a" and "b". *) PROCEDURE EstimateVelocityQ( a: LONG; READONLY pa: Point; b: LONG; READONLY pb: Point; c: LONG; READONLY pc: Point; ): Point; PROCEDURE EstimateVelocityL( a: LONG; READONLY pa: Point; b: LONG; READONLY pb: Point; c: LONG; READONLY pc: Point; ): Point; PROCEDURE EstimateVelocityC( a: LONG; READONLY pa: Point; b: LONG; READONLY pb: Point; c: LONG; READONLY pc: Point; ): Point; (* These procedures return estimates of a curve's velocity at time "b", given its positions "pa", "pb", "pc" at three successive times "a", "b", "c". EstimateVelocityQ uses quadratic interpolation. It is precise for quadratic functions but is unstable when "b" is near "a" or "c". EstimateVelocityL uses linear interpolation between "(a,pa)" and "(c,pc)". It ignores "b" and "pb". It is therefore robust for uneven intervals, but is not precise for quadratics. EstimateVelocityC uses a formula that degenerates to linear interpolation between "(a,pa)" and "(b,pb)" when "b" is close to "c", and to linear interpolation between "(b,pb)" and "(c,pc)" when "b" is close to "a". It thus gives an "unconstrained derivative" effect at double nodes, which is useful for modeling. It is more robust than EstimateVelocityQ, but is not precise for quadratics. *) PROCEDURE HermiteCurveLength( a: LONG; READONLY pa: Point; READONLY va: Point; b: LONG; READONLY pb: Point; READONLY vb: Point; ): LONG; (* Computes the approximate length between "pa" and "pb" of the cubic curve that interpolates "(a,pa)" and "(b,pb)", with velocities "va", "vb" at those points. *) PROCEDURE BSplineApproximation( t: LONG; a: LONG; b: LONG; READONLY Pabc: Point; c: LONG; READONLY Pbcd: Point; d: LONG; READONLY Pcde: Point; e: LONG; READONLY Pdef: Point; f: LONG; ): Point; (* Computes the position at time "t" of a cubic B-Spline curve with control points "Pabc", "Pbcd", "Pcde", "Pdef", and knot sequence "a",... "f". Assumes "t" lies between "c" and "d". *) END PZGeo3.