BrianK Posted September 4, 2004 Share Posted September 4, 2004 Anyone else notice this? Is there a reason? I don't see the ability to do: UT_Matrix3 * UT_Vector3 which used to work in older HDK's (and is proper mathemtically, if I'm not mistaken). any workarounds (other than writing the small piece of code myself)? Quote Link to comment Share on other sites More sharing options...
BrianK Posted September 4, 2004 Author Share Posted September 4, 2004 Anyone else notice this? Is there a reason? 13649[/snapback] hmmm... the smoke has cleared. This is still possible. however, you now have to do: UT_Vector3 = UT_Vector3 * UT_Matrix3 which, correct me if I'm wrong, is backwards. Before, you could do it either way (which I find odd). ... it's been a long time since linear algebra. Is this way right? Quote Link to comment Share on other sites More sharing options...
edward Posted September 4, 2004 Share Posted September 4, 2004 (edited) Ah, I would have thought all the HDK users knew this but I guess not. How about I explain, and you put it up on the wiki? There are two independent things which you need to know about Houdini's matrix classes. These are:1. UT_Vector3's when multiplied with matrices are treated as row vectors.2. They are stored in row-major format.The implication of #1 is that when concatenating transforms, the point is applied to the leftmost matrix first, on its left side. So you usually need to concatenate transforms in the reverse order than what you were taught in class. This also means that when copying matrices from papers that use the column vector convention, you need to transpose the matrices so that they work with row vectors instead. Implication #2 combined with implication #1 means that you can just pass these matrices unchanged to OpenGL, which expects column vectors with column-major matrices.Let's work through some examples to illustrate the first implication and how to use them.UT_Vector3 p;UT_Matrix4 xform1, xform2;// transform the point p in local space by the transform xformp *= xform1;// this is equivalent to:p = p * xform1;// treat the variable p as a direction instead of as a pointp.multiply3( xform1 );// transform the point p first by xform1 and then by xform2// another way to think about this is that xform1 is the parent// space of p and xform2 is the parent transform of xform1p *= xform1;p *= xform2;// another way to do the same thing:p = p * xform1 * xform2;// or ...xform1 *= xform2;p *= xform1;// create a matrix that translates and then scales the point p// note that translate()/scale()/rotate() calls create a// temporary matrix which is then right multiplied with *thisUT_Matrix4 xform( 1.0 ); // start off with identityxform.translate( 1, 2, 3 );xform.scale( 2, 2, 2 );p *= xform;// or in the reverse order ...UT_Matrix4 xform( 1.0 ); // start off with identityxform.prescale( 2, 2, 2 );xform.pretranslate( 1, 2, 3 );p *= xform; Edited June 7, 2014 by edward Corrected implications. Quote Link to comment Share on other sites More sharing options...
edward Posted September 4, 2004 Share Posted September 4, 2004 The operator *(UT_Matrix3, UT_Vector3) function was in fact always doing UT_Vector3 * UT_Matrix3 for you instead, which is wrong and leads to a lot of confusion with using them. So it was removed. Quote Link to comment Share on other sites More sharing options...
BrianK Posted September 4, 2004 Author Share Posted September 4, 2004 Very informative. Thank you! Quote Link to comment Share on other sites More sharing options...
narthe Posted June 4, 2014 Share Posted June 4, 2014 Thanks for this explanation edward Quote Link to comment Share on other sites More sharing options...
br1 Posted June 5, 2014 Share Posted June 5, 2014 How to revive a 10 year-old thread ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.