Jump to content

Extracting Scaling from a Matrix4


Recommended Posts

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?

Link to comment
Share on other sites

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.euclideanspace.com/maths/algebra/matrix/transforms/index.htm

Edited by mightcouldb1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...