|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Say I've got two different expressions or algorithms for defining a transform. I
want to transition from one to the other very gradually as I proceed along a
series of frames. Say a "walk" transform" going to a "run" transform.
Can two different transforms be averaged together? I'm not sure if this would
be trivial or impossible.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Say I've got two different expressions or algorithms for defining a
> transform. I
> want to transition from one to the other very gradually as I proceed along
> a
> series of frames. Say a "walk" transform" going to a "run" transform.
>
> Can two different transforms be averaged together? I'm not sure if this
> would
> be trivial or impossible.
>
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...
// state of animation
#if (frame_number = 1)
#declare old_loc = <-0.1,0,0>;
#else
#fopen File "anim.tmp" read
#read (File, old_loc)
#fclose File
#end
#declare walk_speed= 0.1*clock_delta;
#declare run_speed= 1*clock_delta;
#declare speed = (run_speed-walk_speed)*clock+walk_speed;
#declare dir = <1,0,0>;
#declare loc = transform {translate old_loc + speed*dir};
// scene
// save state
#fopen File "anim.tmp" write
#write File concat("<",vstr(3, loc, ", ", 0,5),">")
#fclose File
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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{};
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> 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.
Also if you are going to calculate your rotations from applied forces and
torques then using quaternions makes matters much simpler.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"scott" <sco### [at] laptopcom> wrote:
> Also if you are going to calculate your rotations from applied forces and
> torques then using quaternions makes matters much simpler.
Sorry to throw a potential proverbial spanner (Am. wrench) in the works but it
does depend on what you mean by 'average'.
Say you wanted a smooth pan across a scene and you're using the 'average
transform' to transform the camera. Then clock*T1 + (1-clock)*T2 works. But
this will pan at an even speed. Often what is required is a build-up of speed,
then constant speed, then an ease down into the final position. At very least
this requires some more fancy work on clock before using it in the above (a
sine**2 function over 90 degrees is a start, but not a very good one).
But consider a transform of a camera that gives the same effect as an object
rotating on a pedestal. Say the rotation is 90 degrees. A linear
interpolation will cause the camera to move along the chord joining the first
and last points, not round the arc. Fine if that's what you want, but it often
isn't.
This in general is also true of transforms of visible objects.
It really depends on the intermediate transforms you want to go through, so is
much more akin to a spline than a straight line. I wrote a whole load of
macros for a previous ray tracing system (Rayshade) that I used for years of
doing scientific animation, and will see whether I can dig them out and change
them from C pre-processor code into POVray macros.
Cheers
Chris
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Just to restate, I have one transform that is, in effect,
#declare First_Trans= transform{
rotate foo1 translate bar1
rotate foo2 translate bar2
rotate foo3 translate bar3
rotate foo4 translate bar4
rotate foo5 translate bar5
rotate foo6 translate bar6
rotate foo7 translate bar7 }
Imagine all the transformations a big toe or index digit has to go through from
the hip. Up the spine, over to shoulder, etc. And then I've got one transform
that describes, as a function of clock, a walk cycle, and another a run.
Now if all transforms are matrices, then I'm guessing a complicated transform,
too, is a matrix. Here's where it may be either incredibly stupid question or
trivial implementation (three lines of SDL or for inclusion in povray 4.1).
Can you simply average all of the components of two different transforms and get
either a meaningful or smooth transition?
\\
"TheOzule" <chr### [at] chris-oslandorguk> wrote:
> It really depends on the intermediate transforms you want to go through, so is
> much more akin to a spline than a straight line. I wrote a whole load of
> macros for a previous ray tracing system (Rayshade) that I used for years of
> doing scientific animation, and will see whether I can dig them out and change
> them from C pre-processor code into POVray macros.
>
> Cheers
>
> Chris
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"gregjohn" <pte### [at] yahoocom> wrote in message
news:web.478ccbf88a803975d30d1e600@news.povray.org...
> Just to restate, I have one transform that is, in effect,
>
> #declare First_Trans= transform{
> rotate foo1 translate bar1
> rotate foo2 translate bar2
> rotate foo3 translate bar3
> rotate foo4 translate bar4
> rotate foo5 translate bar5
> rotate foo6 translate bar6
> rotate foo7 translate bar7 }
>
> Imagine all the transformations a big toe or index digit has to go through
> from
> the hip. Up the spine, over to shoulder, etc. And then I've got one
> transform
> that describes, as a function of clock, a walk cycle, and another a run.
>
> Now if all transforms are matrices, then I'm guessing a complicated
> transform,
> too, is a matrix. Here's where it may be either incredibly stupid question
> or
> trivial implementation (three lines of SDL or for inclusion in povray
> 4.1).
>
> Can you simply average all of the components of two different transforms
> and get
> either a meaningful or smooth transition?
>
Hi Greg,
Yes and No. :-)
There's nothing that I'm aware of that would automatically do this for just
any old transform or for your particular transformations once they're built
up inside the transform statement.
It would, on the other hand, be possible to apply the two different
transformations to a set of four points (centre and 3x axis normals) and
create a macro that interpolates between the end results to give a single
'scale', 'rotate', 'translate' transform - with the consequent problems of
doing such a linear interpolation that Chris described (another Chris).
However, I would think that your particular problem is no more complex than
the one I had in creating POV-Person a few years ago, which incorporates a
macro that calculates an intermediary pose between two hand-coded poses.
Thus the 'walking' animation at http://www.geocities.com/povperson/ only
uses a small number of hand-coded poses and the rest are interpolated. It
can also interpolate between sitting and standing etc, but does look a bit
wooden if you don't add a few extra hand coded positions in between.
When writing that macro I assumed that the 'translates' don't make much
difference because I wasn't expecting the distance between two joints to
change between two poses, so it was just a matter of interpolating between
the individual rotations (stored in an array) before building the final
transformation for each body part.
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
gregjohn wrote:
> Just to restate, I have one transform that is, in effect,
>
> #declare First_Trans= transform{
> rotate foo1 translate bar1
> rotate foo2 translate bar2
> rotate foo3 translate bar3
> rotate foo4 translate bar4
> rotate foo5 translate bar5
> rotate foo6 translate bar6
> rotate foo7 translate bar7 }
>
> Imagine all the transformations a big toe or index digit has to go
> through from
> the hip. Up the spine, over to shoulder, etc. And then I've got one
> transform that describes, as a function of clock, a walk cycle, and
> another a run.
If you have always the same parameters (foo1 to foo7 and bar1 to bar7 in
you example), why do you not simply interpolate all these parameters
themselves (i.e. compute foo1 to foo7 and bar1 to bar7 depending on the
clock value and their start and end value) and compute the
transformation afterwards?
> Now if all transforms are matrices, then I'm guessing a complicated
> transform, too, is a matrix. Here's where it may be either incredibly
> stupid question or trivial implementation (three lines of SDL or for
> inclusion in povray 4.1).
>
> Can you simply average all of the components of two different
> transforms and get
> either a meaningful or smooth transition?
Consider the identity transform and a rotation around an axis by 180
degrees. What do you think is a meaningful transition in this case? In
which direction do you want to rotate? Or would you like to scale
instead of rotate, i.e. scaling along the plane normal to the axis by 1
to -1?
So, "meaningful" is not well defined in this situation. So it would
probably not happen what you intend.
And look also at this start-matrix
1 0 0
0 1 0
0 0 1
And the end-matrix
-1 0 0
0 -1 0
0 0 -1
In this case you will encounter a matrix with only 0 as components,
which does not make much sense.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Urs Holzer wrote:
>> Can you simply average all of the components of two different
>> transforms and get
>> either a meaningful or smooth transition?
>
> Consider the identity transform and a rotation around an axis by 180
> degrees. What do you think is a meaningful transition in this case? In
> which direction do you want to rotate? Or would you like to scale
> instead of rotate, i.e. scaling along the plane normal to the axis by
> 1 to -1?
> So, "meaningful" is not well defined in this situation. So it would
> probably not happen what you intend.
I have to add, that if the matrices differ only slightly, you should try
it anyway. Perhaps the right thing happens in your case.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|