efourier computes Fourier coefficients from a set of coordinates; efourier.i calculates a shape given a set of Fourier coefficients computed with efourier; efourier.shape calculates a "Fourier elliptical shape" given Fourier coefficients (see Details) ; efourier.norm normalizes Fourier coefficients for rotation, tranlation, size and orientation of the first ellipse.efourier(coo, nb.h = 32, smooth.it = 0)
efourier.i(ef, nb.h, nb.pts = 300)
efourier.shape(an, bn, cn, dn, nb.h, nb.pts=80, alpha=2, plot=TRUE)
efourier.norm(ef, start = FALSE)list or a matrix of coordinates.integer. The number of harmonics to useinteger. The number of smoothing iterations to perform.integer. The number of points to calculate.list. A list containing $a_n$, $b_n$, $c_n$ and $d_n$ Fourier coefficients, such as returned by efourier.numeric. The $a_n$ Fourier coefficients on which to calculate a shape.numeric. The $b_n$ Fourier coefficients on which to calculate a shape.numeric. The $c_n$ Fourier coefficients on which to calculate a shape.numeric. The $d_n$ Fourier coefficients on which to calculate a shape.numeric. The power coefficient associated with the (usually decreasing) amplitude of the Fourier coefficients (see Details).logical. Whether to plot or not the shape.logical. Whether to conserve the position of the first point of the outline.vector of $A_{1->n}$ harmonic coefficients.vector of B_{1->n} harmonic coefficients.vector of C_{1->n} harmonic coefficients.vector of D_{1->n} harmonic coefficients.ao Harmonic coefficient.co Harmonic coefficient.vector of x-coordinates.vector of y-coordinates.vector of numeric A_{1->n} normalized harmonic coefficients.vector of numeric B_{1->n} normalized harmonic coefficients.vector of numeric C_{1->n} normalized harmonic coefficients.vector of numeric D_{1->n} normalized harmonic coefficients.list with A, B, C and D concatenated in a vector that may be convenient for some uses.Coo-objects.
Elliptic Fourier analysis and normalization are calculated as follows. Let $T$ be the perimeter of a given closed outline, here considered as the period of the signal. One sets $\omega = 2\pi/T$ to be the pulse. Then, the curvilinear abscissa, $t$ varies from $0$ to $T$. One can express $x(t)$ and $y(t)$ as:
$$x(t) = \frac{a_0}{2}+\sum\limits_{n=1}^{+\infty} a_n\cos n\omega t + b_n\sin n\omega t$$
with
$$a_n = \frac{2}{T}+ \int\limits_{0}^{T} x(t)\cos (n\omega t) \mathrm{d} t$$
$$b_n = \frac{2}{T}+ \int\limits_{0}^{T} x(t)\sin (n\omega t) \mathrm{d} t$$
similarly,
$$y(t) = \frac{c_0}{2}+\sum\limits_{n=1}^{+\infty} c_n\cos n\omega t + d_n\sin n\omega t$$
with
$$c_n = \frac{2}{T}+ \int\limits_{0}^{T} y(t)\cos (n\omega t) \mathrm{d} t$$
$$d_n = \frac{2}{T}+ \int\limits_{0}^{T} y(t)\sin (n\omega t) \mathrm{d} t$$
Since the outline contains a $k$ finite number of points, one can therefore calculate discrete estimators for every harmonic coefficient of the $n^{th}$ harmonics:
$$a_n=\frac{T}{2\pi^2n^2}\sum\limits_{p=1}^k \frac{\Delta x_p}{\Delta t_p}(\cos\frac{2\pi nt_p}{T}-\cos\frac{2\pi nt_{p-1}}{T})$$
$$b_n=\frac{T}{2\pi^2n^2}\sum\limits_{p=1}^k \frac{\Delta x_p}{\Delta t_p}(\sin\frac{2\pi nt_p}{T}-\sin\frac{2\pi nt_{p-1}}{T})$$
$\Delta x_1=x_1-x_k$ and $c_n$ and $d_n$ are calculated similarly. $a_0$ and $c_0$ correspond to the estimate of the coordinates of the centroid of original outline and are estimated by:
$$a_0=\frac{2}{T}\sum\limits_{i=1}^p x_i$$
and
$$c_0=\frac{2}{T}\sum\limits_{i=1}^p y_i$$
Intuitively, for all positive integers $n$, the sum of a cosine curve and a sine curve represent the $n^{th}$ harmonic content of the $x$ and $y$ projections of the $k$-edged polygon, and for any $n$, these two curves define an ellipse in the plane. Ferson and colleagues noticed that in the "time" it takes the $n^{th}$ harmonic to traverse its ellipse $n$ times, the $(n+1)^{th}$ harmonic has traversed its own ellipse $n+1$ times. The reconstruction of the original polygon is done by vector adding these ellipses for all harmonics, which echoes astronomical Ptolemy's epicycles (see Ptolemy), and the reconstruction obtained from $N$ harmonics is the best possible fit in a least-squares sense.
efourier.shape can be used to draw "elliptical Fourier shapes" by specifying nb.h and alpha. The coefficients are then sampled in an uniform distribution $(-\pi ; \pi)$ and this amplitude is then divided by $harmonic_rank^alpha$. If alpha is lower than 1, consecutive coefficients will thus increase.data(bot)
q <- (efourier(bot@coo[[1]]))
efourier.i(q) # equivalent to efourier.shape(q$an, q$bn, q$cn, q$dn)
efourier.norm(q)
efourier.shape(nb.h=5, alpha=1.2)
efourier.shape(nb.h=12, alpha=0.9)Run the code above in your browser using DataLab