|
|
Greg M. Johnson wrote:
> Tim Attwood wrote:
>
>
>> Seems straightforward if you save the location of some
>> object to disk every frame... there's probably a formula
>> for it too, but it doesn't spring to mind, some sort of
>> quadratic...
>>
>
>
> Thanks, but I'm not saving to disk.
>
> It's more like I have pre-defined transforms (which are like
> trans,rotate,trans,rotate,trans,rotate) and want to do:
>
>
> #declare New_Transform= clock * Transform_1{}+ (1-clock)*Transform_2{};
>
You want to interpolate between two transformations. The translations
are trivial to interpolate. The problem is the rotations. Rotations are
represented in POVRay by rotation matrices. Interpolating these in a
natural way is very difficult in general.
One interesting area of mathematics that helps is called quaternions. A
quaternion is an <a, b, c, d> vector which represents a hyper-complex
number ai + bj + ck + d where i, j, and k are all orthogonal imaginary
numbers (visualize i, j and k as x,y,z axes). Imagine that a, b, and c
form a vector that defines the axis of rotation. Whenever the magnitude
of <a b c d> is 1, you get a non-scaling pure rotation about that axis.
By altering d (to be cos(angle/2)) and scaling the vector <a b c> by
sin(angle/2), you can change the angle of rotation about that axis.
I'll leave the math aside (I have some links below) but say that a
quaternion corresponds to a rotation and scaling transformation. You
can convert back and forth from quaternions to 3x3 transformation
matrices. The advantage with quaternions is that you can do quaternion
interpolation. You can use two quaternions representing different
rotations/scalings and a parameter t to calculate an intermediate
rotation/scaling about the appropriate axis. Very cool.
http://web.archive.org/web/20041029003853/http:/www.j3d.org/matrix_faq/matrfaq_latest.html#Q44
http://en.wikipedia.org/wiki/Quaternion
David Buck
Post a reply to this message
|
|