RE: scale retrieval

New Message Reply Date view Thread view Subject view Author view

From: Colin Middleton (colin++at++sgi.com)
Date: 03/12/2001 03:26:34


Mark,

The translation, rotation and scale are all sored in the matrix.

the matrix m can be represented as

m[0][0] m[0][1] m[0][2] m[0][3]
m[1][0] m[1][1] m[1][2] m[1][3]
m[2][0] m[2][1] m[2][2] m[2][3]
m[3][0] m[3][1] m[3][2] m[3][3]

This can be decomposed into 5 3-dimensional vectors

u - unit local X direction
v - unit local Y direction
w - unit local Z direction
t - translation vector
s - scale vector

These values make up the matrix as follows

u[0]s[0] u[1]s[0] u[2]s[0] 0
v[0]s[1] v[1]s[1] v[1]s[2] 0
w[0]s[2] w[1]s[2] w[2]s[2] 0
t[0] t[1] t[2] 1

So we can get the scale vector s by

  pfVec3 u ( mat[0][0] , mat[0][1] , mat [0][2] ) ;
  pfVec3 v ( mat[1][0] , mat[1][1] , mat [1][2] ) ;
  pfVec3 w ( mat[2][0] , mat[2][1] , mat [2][2] ) ;
  pfVec3 t ( mat[3][0] , mat[3][1] , mat [3][2] ) ;

  pfVec3 s ( u . normalize () ,
              v . normalize () ,
              w . normalize () ) ;

In order to animate I suggest that you decompose the matrix into these
vectors,
interpolate them separately and then multiply them back again to get the new
matrix.

You can linearly interpolate s & t . Howeverr if you try to linearly
interpolate u , v and w you will have you model growing and shrinkingin odd
ways. This is because they should be kept as unit vectors.

There are a number of ways to interpolate rotation.

1) Linearly interpolate Euler angles. Get these from pfGetOrthoMatCoord .
These can be linear interpolated but you may see some gimbal lock.

2) Use Spherical Linear interpolation. You can do this by converting the
matrix into a pfQuat and using the slerp function or you can do it directly
on the vectors. The formula for finding the the point c that is the fraction
t of the way between a & b in spherical space is :-

c = ( a * sin ( (1-t) * angle ) + b * sin ( t * angle ) ) / sin ( angle ) ;

Where angle is the angle between the two vectors ( angle = acos ( a.dot(b)))
and a and b are unit vectors.

I hope this helps.

Colin
  

> -----Original Message-----
> From: Mark Evans [mailto:mrrevans++at++yahoo.com]
> Sent: 09 March 2001 11:19
> To: info-performer++at++sgi.com
> Subject: scale retrieval
>
>
> Is it possible to retrieve the rotation, translation
> and scale for a pfDCS ( or pfSCS) separately? You can
> set separately the translation, rotation and scale for
> a pfDCS (through pfDCSTrans, pfDCSRot, pfDCSScale,
> pfDCSScaleXYZ), but you can only retrieve the matrix
> of a pfDCS (pfGetDCSMat). Is it possible to retrieve,
> from this matrix, the translation, rotation and scale?
> I've tried to use pfGetOrthoMatCoord, but it would
> only get me the translation and rotation, not the
> scale.
> Is there a unique solution, or could different
> rotations+scales to give the same result?
> Also, if I want to "animate" a pfDCS from pfMatrix m1
> to pfMatrix m2 through linear interpolation, is it
> correct to linearly interpolate each of the 16
> coefficients of the matrix for the pfDCS between the
> source and destination matrices? Is there a better (or
> correct) way?
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
> --------------------------------------------------------------
> ---------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>

___________________________________________
Colin Middleton,
SGI Professional Services,
1530 Arlington Business Park,
Theale, Reading, Berks. RG7 4SB.
United Kingdom.
Tel: +44 (0)118 9257692
Mobile: +44 (0)780 1623221
email: colin++at++sgi.com

NB: information in this message is SGI confidential. It is intended solely
for the person(s) to whom it is addressed and may not be copied, used,
disclosed or distributed to others without SGI consent. If you are not the
intended recipient please will you notify me by email or telephone, delete
the message from your system immediately and destroy any printed copies.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Mar 12 2001 - 03:27:48 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.