INTERFACE PZCurve; (* Closed C_1 cubic splines *) (* Last edited on 1999-08-15 10:26:47 by hcgl *) IMPORT LR3, PZLR3Chain, PZLRChain; FROM PZTypes IMPORT LONG, NAT; 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: NAT; (* 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]". *) r: REF PZLRChain.T; (* "r[i]" is the label function at time "t[i]". *) rPeriod: LONG; (* Label period. *) d: REF PZLR3Chain.T; (* "d[i]" is the est. curve direction "p[i]". *) (* A "PZCurve.T "c" represents a closed parametric curve, i.e. a periodic function "c.p(t)" from a "time" parameter "t" into the space R^3, The curve is `almost always' G1-smooth, i.e. the tangent direction is defined at all times, except for a zero-measure subset of configurations of the samples "p[i]". The curve "c.p(t)" 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". The set of points traversed by the curve does not depend on the times "c.t[i]" or the labels "c.r[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 of the curve "c" 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". *) uniformize(); (* Changes the curve's parametrization to the natural (arc-length) one Specifically, sets "c.t[i]" to the length of the curve between "c.p[0]" and "c.p[i]". On output, "c.tPeriod" will be equal to "c.length". The sample positions and labels are not changed. *) setToFiltered(d: T; sigma: LONG); (* The call "c.setToFiltered(d, sigma)" replaces the curve "c" by a version of curve "d", convolved with a unit-area parametric Gaussian with characteristic duration "sigma", and then sampled at "c.m" equally spaced times. The original curve "d" is not changed. *) eval(t: LONG; VAR p, v: LR3.T; VAR r: LONG); (* Returns the curves's position "p", velocity "v", and label "r" at time "t". *) 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: NAT): 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. (* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. *)