Tuesday, October 18, 2016

A Note on Projective Splines

In this post, I'll make a seemingly in-obvious remark on the great work of Projective Splines by Thomas Lewiner and Marcos Craizer. Special thanks to Marcos Craizer for the discussion. The paper of interest is Projective splines and estimators for planar curves. The goal of the paper is an invariant spiral construction in the canonical projective frame. The setting looks like:
The idea is to use \(3\) points augmented by the tangents to generate new points and exploit the cross ratio in estimation of two projective invariants: projective length and projective curvature. The spline construction is basically done by solving a linear system in Section 3c. There, the last pair of equations require \((P_{x,3},P_{y,3})\), which are not explicitly given in the paper. Here I'll provide the expression for that: Following Section 3a, knowing \(P\), the standard spiral, the spiral corresponding to the newly generated point \(x_{i,3}\) could be written as \(\mathbf{P}_3(\sigma_i) = \mathbf{P}(\sigma_i) + t\mathbf{W}\). Here $$W(\sigma)=a e^{a\sigma}$$ and \(t\) is given in Section 3a. Also, \(a=\frac{3}{2}+\frac{i\sqrt{3}}{2}\). Here the complex notation is used to jointly represent coordinates \((x,y)\). If we plug \(a\) into \(W\): $$ \begin{align*} W(\sigma)&=a e^{a\sigma}\\ &=(\frac{3}{2}+\frac{i\sqrt{3}}{2}) e^{3\sigma/2} e^{\sqrt{3}i\sigma/2} \\ &=(\frac{3}{2}e^{3\sigma/2}+\frac{i\sqrt{3}}{2}e^{3\sigma/2}) e^{\sqrt{3}i\sigma/2} \\ &=\bigg(\frac{3}{2}e^{3\sigma/2}+\frac{i\sqrt{3}}{2}e^{3\sigma/2}\bigg) \bigg(cos(\frac{\sqrt{3}\sigma}{2})+i sin(\frac{\sqrt{3}\sigma}{2})\bigg) \text{ (via Euler's Formula)}\\ \text{fast forwarding...} & \\ &=\frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} cos(\frac{\sqrt{3}\sigma}{2}) - sin(\frac{\sqrt{3}\sigma}{2}) \bigg) + i \frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} sin(\frac{\sqrt{3}\sigma}{2}) + cos(\frac{\sqrt{3}\sigma}{2}) \bigg) \end{align*} $$ We could now define the vector \(\mathbf{W}\) to be: $$ \mathbf{W} = (W_x, W_y, W_z)^T = \begin{bmatrix} \frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} cos(\frac{\sqrt{3}\sigma}{2}) - sin(\frac{\sqrt{3}\sigma}{2}) \bigg) \\ \frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} sin(\frac{\sqrt{3}\sigma}{2}) + cos(\frac{\sqrt{3}\sigma}{2}) \bigg) \\ 1 \end{bmatrix} $$ Note that the linear system uses only two components of \(\mathbf{P}_3\), letting us to set \(W_z=w=1\). Now, let's get back to Section 2b to define: $$ \mathbf{P} = (P_x, P_y, P_z) = \begin{bmatrix} e^{\sigma/2}cos(\frac{\sqrt{3}\sigma}{2})\\ e^{\sigma/2}sin(\frac{\sqrt{3}\sigma}{2})\\ e^{-\sigma} \end{bmatrix} $$ being the components of standard spiral. To obtain the projective curve at w=1, we have to multiply all components by \(e^{\sigma}\). Plugging in \(\mathbf{P}_3(\sigma_i) = \mathbf{P}(\sigma_i) + t\mathbf{W}\) results in: $$ \mathbf{P}_3 = (P_{x,3}, P_{y,3}, P_{z,3})^T = \begin{bmatrix} e^{3\sigma/2}cos(\frac{\sqrt{3}\sigma}{2}) + t \frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} cos(\frac{\sqrt{3}\sigma}{2}) - sin(\frac{\sqrt{3}\sigma}{2}) \bigg) \\ e^{3\sigma/2}sin(\frac{\sqrt{3}\sigma}{2}) + t\frac{\sqrt{3}}{2} e^{3\sigma/2} \bigg( \frac{\sqrt{3}}{2} sin(\frac{\sqrt{3}\sigma}{2}) + cos(\frac{\sqrt{3}\sigma}{2}) \bigg) \\ t \end{bmatrix} $$ Here is the MATLAB code:
% requires P (the standard spiral), t (step), sigma (projective length)
% computes the canonical coordinate P_3
function [P3] = compute_p3(P, t, sigma)
s32 = sqrt(3)/2;
coeff = s32 * exp(1.5*sigma);
W = [
    coeff .* (s32.*cos(s32.*sigma) - sin(s32.*sigma));
    coeff .* (s32.*sin(s32.*sigma) + cos(s32.*sigma));
       1
];
P3 = P + t.*W;
end

No comments: