5
$\begingroup$

I am using the following equation to create a cubic hermite spline:

$$p_n(t) = a_nt^3+b_nt^2+c_nt+d_n$$ $$1\geq t\geq 0$$ $p_n(t)$ is the unit interval interpolation equation for dimension n. $t$ is the parametric variable.

This was rearranged from Wikipedia and I simplified the equation as the implementation is unimportant here.

I need to calculate the length of the interpolated spline and for that I am using the following equation to calculate the length: $$ s = \int_0^1 \sqrt[2]{\dot{p}_x(t)^2+\dot{p}_y(t)^2+\dot{p}_z(t)^2} dt $$

$$\dot{p}_n(t) = 3a_nt^2+2b_nt+c_n$$

$\dot{p}_n(t)$ is the first derivative of the interpolation equation with respect to $t$.

After subbing in all the relevant equations I get the following: $$s = \int_0^1 \sqrt[2]{9(\boldsymbol{A}\cdot\boldsymbol{A})t^4 + 12(\boldsymbol{A}\cdot\boldsymbol{B})t^3 + (6(\boldsymbol{A}\cdot\boldsymbol{C})+4(\boldsymbol{B}\cdot\boldsymbol{B}))t^2 + 4(\boldsymbol{B}\cdot\boldsymbol{C})t + \boldsymbol{C}\cdot\boldsymbol{C}} dt$$ $$\boldsymbol{A} = \begin{pmatrix}a_x\\a_y\\a_z\end{pmatrix}$$ I vectorised it for brevity and it also lets me do a sneaky trick (atleast I think its a sneak trick). I noticed that the polynomial inside the square root looked similar to $\dot{p}_n(t)^2$ and since $\boldsymbol{A}\cdot\boldsymbol{A}=|\boldsymbol{A}|^2$I figured the following is possible:

$$s = \int_0^1 \sqrt[2]{(3\boldsymbol{|A|}t^2 + 2\boldsymbol{|B|}t + \boldsymbol{|C|})^2} dt$$

After integrating I get the following solution: $$s=\boldsymbol{|A|}+\boldsymbol{|B|}+\boldsymbol{|C|}$$

However, on implementing this I find that the values it produces are wrong. In the image below the straight green line in the centre of the image has a length of approximately 6 units and the solution I derived gives a spline length of 15 units. If the spline did have a length of 15 units then it should follow a path similar to a semi-circle.

I'm not entirely sure where I went wrong here, my best guess is that missed something when I vectorised the equation but I can't seem to figure out what I did wrong. I would appreciate any help.

After implementing

Note: The spline is described by the path of squares which go from one end of a line to another.

$\endgroup$
1
  • 1
    $\begingroup$ For reference to anyone looking to calculate the length of cubic splines. The integral cannot be computed analytically and so a numerical method is required. I would recommend the Runge Kutta method as it is can be quickly implemented and is reasonably accurate. $\endgroup$ Jul 12, 2014 at 23:16

1 Answer 1

3
$\begingroup$

The problem is that while $|A\cdot A| = |A|^2$ it is not true that $|A\cdot B| = |A|\cdot |B|$. So the trick is not valid...

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .