Hi,
I can't seem to figure out how to do the following: how can I rewrite a standard 2D Hermite spline (as in the picture below) into a "V as a function of T"-form? I've imported timeline-curves like these from a 3D animation app, but I can't get the animation to behave exactly like it does in the app.
[Edited by - eppo on August 21, 2009 5:47:14 AM]

**0**

# Hermite splines

Started by eppo, Aug 20 2009 10:11 PM

5 replies to this topic

###
#2
Members - Reputation: **1161**

Posted 21 August 2009 - 03:30 AM

For a 2D spline, you have V(t) = a0 + a1*t + a2*t^2 + a3*t^3. The following boundary conditions are specified by you: V(0), V'(0), V(1), and V'(1). The construction of a0 through a3 is just like you do for 3D splines. Have you tried this? And if so, what appears to be the conceptual difference between V(t) and what you see in your application?

###
#4
Members - Reputation: **1161**

Posted 21 August 2009 - 10:04 AM

What I suggested is "1D splines". The a0, a1, a2, and a3 are scalars (1-tuples), not 2-tuples. I use "t" rather than "T" for the independent variable, because "T" looks too much like the name of a tangent vector :)

The 1D-spline approach produces V(t) = a0 + a1*t + a2*t^2 + a3*t^3, where a0 = V(0), a1 = V'(0), a2 = 3*(V(1)-V(0)-V'(0)) - (V'(1)-V'(0)), and a3 = (V'(1)-V'(0)) - 2*(V(1)-V(0)-V'(0)).

The 2D-spline approach fits a curve (x(t),y(t)) = b0 + b1*t + b2*t^2 + b3*t^3, where b0, b1, b2, and b3 are 2-tuples. Your boundary conditions are (x(0),y(0)) = (0,V(0)), (x'(0),y'(0)) = (1,V'(0)), (x(1),y(1)) = (1,V(1)), and (x'(1),y'(1)) = (1,V'(1)). The algebra gets you to b0 = (0,V(0)), b1 = (1,V'(0)), b2 = 3*[(1,V(1)) - (0,V(0)) - (1,V'(0))] - [(1,V'(1)) - (1,V'(0))], and b3 = [(1,V'(1)) - (1,V'(0))] - 2*[(1,V(1)) - (0,V(0)) - (1,V'(0))].

If you extract the x-component from the 2D-spline approach, you get x(t) = t. The y-component is y(t) = V(t), where V(t) is what you fit with the 1D-spline approach. So in this case, the two approaches give you the same thing.

The difference between the 1D-spline and 2D-spline methods would be when you specify tangents (x'(0),y'(0)) and (x'(1),y'(1)) where x'(0) is NOT 1 and y'(0) is NOT 1.

The 1D-spline approach produces V(t) = a0 + a1*t + a2*t^2 + a3*t^3, where a0 = V(0), a1 = V'(0), a2 = 3*(V(1)-V(0)-V'(0)) - (V'(1)-V'(0)), and a3 = (V'(1)-V'(0)) - 2*(V(1)-V(0)-V'(0)).

The 2D-spline approach fits a curve (x(t),y(t)) = b0 + b1*t + b2*t^2 + b3*t^3, where b0, b1, b2, and b3 are 2-tuples. Your boundary conditions are (x(0),y(0)) = (0,V(0)), (x'(0),y'(0)) = (1,V'(0)), (x(1),y(1)) = (1,V(1)), and (x'(1),y'(1)) = (1,V'(1)). The algebra gets you to b0 = (0,V(0)), b1 = (1,V'(0)), b2 = 3*[(1,V(1)) - (0,V(0)) - (1,V'(0))] - [(1,V'(1)) - (1,V'(0))], and b3 = [(1,V'(1)) - (1,V'(0))] - 2*[(1,V(1)) - (0,V(0)) - (1,V'(0))].

If you extract the x-component from the 2D-spline approach, you get x(t) = t. The y-component is y(t) = V(t), where V(t) is what you fit with the 1D-spline approach. So in this case, the two approaches give you the same thing.

The difference between the 1D-spline and 2D-spline methods would be when you specify tangents (x'(0),y'(0)) and (x'(1),y'(1)) where x'(0) is NOT 1 and y'(0) is NOT 1.

###
#5
Members - Reputation: **113**

Posted 22 August 2009 - 09:32 AM

Seeing as Ive been doing this for the past two months I hope I can answer this right :D

You have 4 conditions to satisfy:

value continuity at two ends, and

derivative continuity at two ends.

four conditions implies 4 term polynomial:

ax^3 + b*x^2 + c*x + d = f(x)

So there are TWO choices from here: the general approach, and the specific approach.

I prefer the general approach so I'll only cover that:

The function f(x) can be written as:

value_at_node1 * N1(x) + value_at_node2 * N2(x) + slope_at_node1 * N3(x) + slope_at_node2 * N4(x)

where N1,2,3, and 4 are four different polynomials.

N1 and N2 provide value continuity and N3 and N4 provide derivative continuity.

Setup a matrix equation to solve the coeffecicents of these polynomials:

[ x1^3 x1^2 x1 1 ] [ a1 a2 a3 a4 ] [1 0 0 0 ]

[ x2^3 x2^2 x2 1 ] [ b1 b2 b3 b4 ] [0 1 0 0 ]

[ 3x1^2 2x1 1 0 ] X [ c1 c2 c3 c4 ] = [0 0 1 0 ]

[ 3x2^2 2x2 1 0 ] [ d1 d2 d3 d4 ] [0 0 0 1 ]

Solve this for the matrix with all of the a,b,c,d's in it.

The coefficients a,b,c,d correspond to a particular N(x) function.

Ni(x) = ai * x^3 + bi * x^2 + ci * x + di

Using that information you can set the four value you know to create the desired curve.

For more information look into FEM interpolation polynomials for C1 continuous systems.

Good luck and feel free to ask for more detail if you want :D

You have 4 conditions to satisfy:

value continuity at two ends, and

derivative continuity at two ends.

four conditions implies 4 term polynomial:

ax^3 + b*x^2 + c*x + d = f(x)

So there are TWO choices from here: the general approach, and the specific approach.

I prefer the general approach so I'll only cover that:

The function f(x) can be written as:

value_at_node1 * N1(x) + value_at_node2 * N2(x) + slope_at_node1 * N3(x) + slope_at_node2 * N4(x)

where N1,2,3, and 4 are four different polynomials.

N1 and N2 provide value continuity and N3 and N4 provide derivative continuity.

Setup a matrix equation to solve the coeffecicents of these polynomials:

[ x1^3 x1^2 x1 1 ] [ a1 a2 a3 a4 ] [1 0 0 0 ]

[ x2^3 x2^2 x2 1 ] [ b1 b2 b3 b4 ] [0 1 0 0 ]

[ 3x1^2 2x1 1 0 ] X [ c1 c2 c3 c4 ] = [0 0 1 0 ]

[ 3x2^2 2x2 1 0 ] [ d1 d2 d3 d4 ] [0 0 0 1 ]

Solve this for the matrix with all of the a,b,c,d's in it.

The coefficients a,b,c,d correspond to a particular N(x) function.

Ni(x) = ai * x^3 + bi * x^2 + ci * x + di

Using that information you can set the four value you know to create the desired curve.

For more information look into FEM interpolation polynomials for C1 continuous systems.

Good luck and feel free to ask for more detail if you want :D

###
#6
Crossbones+ - Reputation: **4265**

Posted 25 August 2009 - 12:00 AM

Thanks for your replies.

I'm not sure they can help me fix my problem though. This page discusses the same issue I'm having. Basically, my mistake was the idea that for any t, x would be equal on a 2d curve. But the solution they offer with the cubic bezier approximation seems a little archaic to me.

I'm not sure they can help me fix my problem though. This page discusses the same issue I'm having. Basically, my mistake was the idea that for any t, x would be equal on a 2d curve. But the solution they offer with the cubic bezier approximation seems a little archaic to me.