POV-Ray : Newsgroups : povray.general : Math question regarding interpolation of orientations Server Time
5 Nov 2024 14:24:35 EST (-0500)
  Math question regarding interpolation of orientations (Message 1 to 5 of 5)  
From: Sascha Ledinsky
Subject: Math question regarding interpolation of orientations
Date: 28 Jan 2005 15:22:07
Message: <41fa9eef@news.povray.org>
I have a question about interpolating orientations:

I have a set of timestamp/orientation pairs (the orientations are 
represented as unit quaternions), and now I'd like to interpolate them 
to get a smooth animation. Simple cubic interpolation works, but is not 
optimal.
I've read that orientations should be interpolated using slerp 
(spherical linear interpolation) - this would ensure that the 
interpolated points are on the (4d) sphere are on a great circle 
representing the shortest distance between the two orienations.
So far so good, but I'd need cubic interpolation... Is there something 
like "spherical cubic interpolation" ?

Perhaps someone already wrote some POV-Ray macros or other code that 
does what I'm looking for and would share it?
Or know a link to a paper about that topic...?

Thanks a lot!

-Sascha Ledinsky


Post a reply to this message

From: Tim Nikias
Subject: Re: Math question regarding interpolation of orientations
Date: 28 Jan 2005 17:20:04
Message: <41faba94@news.povray.org>
Slerp is a very simple algorithm, once you've understood the basics. To
slerp-interpolate, you still use a linear parameter t, just that it is used
as a multiplier for an angle inside a sine-evaluation.

So, you could still just go ahead and interpolate t cubic instead of linear,
and there you go: cubic slerp interpolation.

The formula for the slerp is this:

q1 and q2 are two quaternions, alpha is the angle between the two,
calculated like this:
alpha = acos( s1*s2+vdot(v1,v2)) , where s1 and s2 are the real parts of the
quaternion, and v1 and v2 are the imaginary vector parts.

So q(t) = (sin((1-t)*alpha)/sin(alpha))*q1 + (sin(t*alpha)/sin(alpha))*q2

With a little googling and some math you should be able to get this working
properly.

Regards,
Tim

PS: I'm planning to implement quaternions and interpolations etc myself at
some point, but am currently occupied with some exams and my hair-macros...
;-)

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: Math question regarding interpolation of orientations
Date: 29 Jan 2005 06:17:44
Message: <41fb70d8$1@news.povray.org>
Thanks Tim!

The only thing I don't understand is "you could still just go ahead and 
interpolate t cubic instead of linear"... Wouldn't I need additional 2 
quaternions (that is, q0, q1, q2 and q3) to cubically interpolate 
between q1 and q2 (to construct something like a catmull-rom spline)?

But well, I'll first start with implementing the slerp formula and see 
how far I get with cubic interpolation. Maybe I'll be back with some 
more questions :-)

Thanks again,
-Sascha

But well, I'll first start with implementing the slerp formula
Tim Nikias wrote:
> Slerp is a very simple algorithm, once you've understood the basics. To
> slerp-interpolate, you still use a linear parameter t, just that it is used
> as a multiplier for an angle inside a sine-evaluation.
> 
> So, you could still just go ahead and interpolate t cubic instead of linear,
> and there you go: cubic slerp interpolation.
> 
> The formula for the slerp is this:
> 
> q1 and q2 are two quaternions, alpha is the angle between the two,
> calculated like this:
> alpha = acos( s1*s2+vdot(v1,v2)) , where s1 and s2 are the real parts of the
> quaternion, and v1 and v2 are the imaginary vector parts.
> 
> So q(t) = (sin((1-t)*alpha)/sin(alpha))*q1 + (sin(t*alpha)/sin(alpha))*q2
> 
> With a little googling and some math you should be able to get this working
> properly.
> 
> Regards,
> Tim
> 
> PS: I'm planning to implement quaternions and interpolations etc myself at
> some point, but am currently occupied with some exams and my hair-macros...
> ;-)
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Math question regarding interpolation of orientations
Date: 29 Jan 2005 06:45:01
Message: <41fb773d@news.povray.org>
> The only thing I don't understand is "you could still just go ahead and
> interpolate t cubic instead of linear"... Wouldn't I need additional 2
> quaternions (that is, q0, q1, q2 and q3) to cubically interpolate
> between q1 and q2 (to construct something like a catmull-rom spline)?

Oh, now I understand! Well, I thought you were after an interpolation which
would start slow, and end slow, which would give a smooth impression. As
value t is just moving from 0 to 1 in a linear fashion, the resulting
quaternion would be a linearly paced interpolation of the two original
quaternions.

If you're after cubic interpolation with 4 or more control quaternions, well
then... Ehm... I can't help you much there, but I guess with a little
brainpower you should be able to dissect the cubic interpolation and just
figure or experiment where and how to use the slerp.Somehow. Like, eh, yeah!
;-)

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Sascha Ledinsky
Subject: Re: Math question regarding interpolation of orientations
Date: 29 Jan 2005 09:57:36
Message: <41fba460@news.povray.org>
:-)

Ok, I'll try some more googling and start experimenting...
Thanks anyway!

-Sascha


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.