POV-Ray : Newsgroups : povray.general : Averaging transforms Server Time
31 Jul 2024 06:21:38 EDT (-0400)
  Averaging transforms (Message 8 to 17 of 17)  
<<< Previous 7 Messages Goto Initial 10 Messages
From: Chris B
Subject: Re: Averaging transforms
Date: 15 Jan 2008 11:23:27
Message: <478cddff$2@news.povray.org>
"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

From: Urs Holzer
Subject: Re: Averaging transforms
Date: 15 Jan 2008 11:23:27
Message: <478cddff$1@news.povray.org>
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

From: Urs Holzer
Subject: Re: Averaging transforms
Date: 15 Jan 2008 11:41:05
Message: <478ce221@news.povray.org>
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

From: gregjohn
Subject: Re: Averaging transforms
Date: 15 Jan 2008 18:55:01
Message: <web.478d46d38a80397534d207310@news.povray.org>
Okay, maybe the is the way to do it: apply the two transforms to the same stick,
then average the sticks, then extract a new transform out of the new stick.   I
tried to posit this in SDL but my head started to hurt.


Post a reply to this message

From: Massimo Valentini
Subject: Re: Averaging transforms
Date: 16 Jan 2008 07:09:41
Message: <478df405@news.povray.org>
"gregjohn" ha scritto 
> Okay, maybe the is the way to do it: apply the two transforms to the same stick,
> then average the sticks, then extract a new transform out of the new stick.   I
> tried to posit this in SDL but my head started to hurt.
> 

Following there's a sketch to extract the rows of the matrix
from a generic transformation and blend them in an
'average' transform.

HTH Massimo
 


#declare T1 = transform { rotate 30 * z }
#declare T2 = transform { scale <.75, 1.25, 1> }

#declare F1 = function { transform { T1 } }
#declare F2 = function { transform { T2 } }

#declare Row3 = F2(0 0 0) * clock + F1(0 0 0) * (1 - clock);
#declare Row0 = F2(1 0 0) * clock + F1(1 0 0) * (1 - clock) - Row3;
#declare Row1 = F2(0 1 0) * clock + F1(0 1 0) * (1 - clock) - Row3;
#declare Row2 = F2(0 0 1) * clock + F1(0 0 1) * (1 - clock) - Row3;

#declare T12 = transform { matrix 
< Row0.x, Row0.y, Row0.z
, Row1.x, Row1.y, Row1.z
, Row2.x, Row2.y, Row2.z
, Row3.x, Row3.y, Row3.z>}

light_source { 0, rgb 1}
background { rgb 1}
box { -.25, .25 transform {T12} translate z pigment {red 1} }
box { -.25, .25 transform {T1} translate z+.0001 pigment {green .5}}
box { -.25, .25 transform {T2} translate z+.0001 pigment {green .5}}


Post a reply to this message

From: Warp
Subject: Re: Averaging transforms
Date: 16 Jan 2008 07:18:42
Message: <478df622@news.povray.org>
Massimo Valentini <not### [at] vailableinvalid> wrote:
> Following there's a sketch to extract the rows of the matrix
> from a generic transformation and blend them in an
> 'average' transform.

  If I'm not mistaken, if you simply average two transformation matrices,
the transformations in-between will be quite distorted. You won't get nice
rotations and translations.

-- 
                                                          - Warp


Post a reply to this message

From: Massimo Valentini
Subject: Re: Averaging transforms
Date: 16 Jan 2008 13:01:31
Message: <478e467b@news.povray.org>
"Warp" ha scritto 
> Massimo Valentini <not### [at] vailableinvalid> wrote:
> > Following there's a sketch to extract the rows of the matrix
> > from a generic transformation and blend them in an
> > 'average' transform.
> 
>   If I'm not mistaken, if you simply average two transformation matrices,
> the transformations in-between will be quite distorted. You won't get nice
> rotations and translations.
> 

It is an interpolation, if you don't get nice rotations and translations
you may add a third transformation in-between, or a third and a fourth
or ...

Massimo


Post a reply to this message

From: SharkD
Subject: Re: Averaging transforms
Date: 16 Jan 2008 15:10:01
Message: <web.478e63db8a803975368884fc0@news.povray.org>
"gregjohn" <pte### [at] yahoocom> wrote:
> 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.

There's no reason why this wouldn't be possible. I'd have to see the actual code
to make suggestions, as I haven't personally experimented with human motion
animations and can't refer to memory.


Post a reply to this message

From: SharkD
Subject: Re: Averaging transforms
Date: 16 Jan 2008 19:00:00
Message: <web.478e9a748a803975368884fc0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "gregjohn" <pte### [at] yahoocom> wrote:
> > 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.
>
> There's no reason why this wouldn't be possible. I'd have to see the actual code
> to make suggestions, as I haven't personally experimented with human motion
> animations and can't refer to memory.

Scratch that. What you want to do is create a single equation for both cases
that takes into account a variable, "speed". As speed increases, the animation
transitions from "walking" to "running".


Post a reply to this message

From: John VanSickle
Subject: Re: Averaging transforms
Date: 17 Jan 2008 18:07:23
Message: <478fdfab$1@news.povray.org>
gregjohn wrote:
> 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.

Generally, the best way to average two transforms is to extract the 
scale, rotation, and translation transforms from each, interpolate the 
results, and then recombine the interpolated values.

(This all assumes that there is no shearing element in the transforms.)

The scale transform you can either scale in a linear fashion:
	s(x) = a+(b-a)*x
or an exponential fashion
	s(x)=a* exp( ln(b/a)*x )

Try each to see which gives you the results you want.

The transform is easily interpolated:
	t(x) = a+(b-a)*x

The rotation will probably be rather complex, and you may want to break 
down the translation into the three axes first, interpolate between the 
axes, and then recombine them.

Regards,
John


Post a reply to this message

<<< Previous 7 Messages Goto Initial 10 Messages

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