INTERFACE PZCurve; (* Closed C_1 cubic splines *) IMPORT PZLR3Chain, PZLRChain; TYPE LONG = LONGREAL; TYPE T <: Public; (* A closed C_1 cubic spline curve. *) Public = OBJECT (* The following fields are read-only; use the methods to change them. *) m: CARDINAL; (* Number of nodes. *) t: REF PZLRChain.T; (* "t[i]" is a node (sampling time). *) tPeriod: LONG; (* Time period *) p: REF PZLR3Chain.T; (* "p[i]" is the position at time "t[i]". *) s: REF PZLRChain.T; (* "s[i]" is the length from "p[i-1]" to "p[i]". *) length: LONG; (* Total length of curve *) r: REF PZLRChain.T; (* "r[i]" is the label function at time "t[i]". *) rPeriod: LONG; (* Label period. *) (* A PZCurve.T "c" is conceptually a closed C_1 parametric curve, i.e. a periodic C_1 function "c.p(t)" from a "time" parameter "t" into the space R^3. The curve is defined so that "c.p(t) = c.p[i]" when "t = c.t[i]", for "i IN [0..c.m-1]"; and also "c(t + c.tPeriod) = c(t)" for all "t". The nodes (sampling times) "t[i]" are a strictly increasing sequence in "[0 _ c.tPeriod)". For each time value "t", the curve also assigns a numeric label "c.r(t)", which is a monotonically increasing continuous function of reals to reals, such that "c.r(t + c.tPeriod) = c.r(t) + c.rPeriod", for all "t". The label value at time 'c.t[i]" is "c.r[i]", for all "i". *) METHODS setSamples(READONLY p: PZLR3Chain.T); (* Modifies the curve "c" so that it goes through point "p[i]", for "i" in "[0..c.m-1]". Requires "NUMBER(p) = c.m". Recomputes the lengths "c.s[i]". Preserves the times "c.t[i]" and the labels "c.r[i]". *) setLabels(READONLY r: PZLRChain.T; rPeriod: LONG); (* Modifies the labeling function so that it has period "rPeriod" and value "r[i]" at time "c.t[i]", for all "i" in "[0..c.m-1]". Preserves the positions "c.p[i]", sampling times "c.t[i]", and lengths "c.s[i]". Requires "NUMBER(r) = c.m". *) setTimes(READONLY t: PZLRChain.T; tPeriod: LONG); (* Sets the curve's period to "tPeriod" and the node times "c.t[i]" to "t[i]", for all "i", without changing the sample positions "c.p[i]" or the labels "c.r[i]". Requires "NUMBER(t) = c.m". *) filter(d: T; sigma: LONG); (* Replaces the curve by a version of curve "d", convolved with a unit-area parametric Gaussian with characteristic duration "sigma", and then sampled at "d.m" equally spaced times. The original curve "d" is not changed. *) sample(READONLY t: PZLRChain.T; VAR p, v: PZLR3Chain.T; VAR r: PZLRChain.T); (* Returns the curves's position "p[k]", velocity "v[k]", and label "r[k]" at time "t[k]", for "k IN [0..LAST(t)]". *) copy(): T; (* Makes a copy of curve "c", so that no subsequent call to a method of "c" will affect the copy (or vice-versa). *) diff(): T; (* Returns an approximate derivative of curve "c", with same number of sample points. The curve "c" is smoothed so that its derivative is still C_1. *) END; PROCEDURE New(m: CARDINAL): T; (* Allocates a new curve "c" with space for "m" sample points. The nodes "c.t[i]" and the labels "c.r[i]" will be uniformly spaced. The sample points will be all zeros. *) END PZCurve.