Extracting Scaling from a Matrix4

4 replies to this topic

#1 Neo

Neo

Peon

• Members
• 14 posts
• Joined: 28-May 12
• Name:Yves Perron

Posted 05 June 2012 - 10:23 AM

Greetings,

I need to interpolate transformations between two matrices, unless there is a fucntion that do just that, I need to extract all transformations separately and interpolate the transformations one by one and rebuild a new matrix from the result. To help me in this process, UT_DMatrix4::getTranslates and UT_DMatrix4::extractRotation are very handy but my question is:

How do we get the scaling from a UT_DMatrix4?

#2 mightcouldb1

mightcouldb1

Illusionist

• Members
• 302 posts
• Joined: 22-May 09
• Location:FarmVille
• Name:Jason Burton

Posted 05 June 2012 - 08:19 PM

I'm not sure if there is a method off of the top of my head.

You could extract the scale by taking vec3.x = matrix4[0][0], vec3.y = matrix4[1][1], vec3.z = matrix4[2][2] since the scale is stored along the diagonal.

I suggest looking at spherical linear interpolation.  I think that there would be a slerp and lerp function in the HDK for matrices.

Edit:
Also, this website is very good.
http://www.euclidean...forms/index.htm

Edited by mightcouldb1, 05 June 2012 - 08:19 PM.

#3 0rr

0rr

Peon

• Members
• 63 posts
• Joined: 17-August 08
• Name:christoph -

Posted 06 June 2012 - 12:53 AM

You can use the explode method do get sperate translation,scale and rotation matrices.
|||  deskriptiv
|||  flickr

#4 edward

edward

Grand Master

• Members
• 3,326 posts
• Joined: 10-September 02
• Name:e.d.w.a.r.d. .

Posted 07 June 2012 - 08:20 PM

If you want to do it the "best" way, you should use UT_Matrix3::splitRotationScale() (assign to a UT_Matrix3 variable from your UT_Matrix4 variable to use the method). This gives you back rotation/scale matrices which can then be extracted for interpolation (UT_Quaternion for the rotation, component-wise interpolation for the scale). For an idea of what could go wrong for bad cases, look at the pictures from this 1992 paper http://research.cs.w...olar-decomp.pdf
don't panic!

#5 Neo

Neo

Peon

• Members
• 14 posts
• Joined: 28-May 12
• Name:Yves Perron

Posted 19 June 2012 - 09:33 AM

Thank you all for your suggestions, I managed to exorcised any Math reference whit my own library. Much simpler that way.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users