Jump to content

H7 HDK: Cant multiply matrix & vector any more?


Recommended Posts

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?

Link to comment
Share on other sites

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? smile.gif

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 xform
p *= xform1;
// this is equivalent to:
p = p * xform1;


// treat the variable p as a direction instead of as a point
p.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 xform1
p *= 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 *this
UT_Matrix4 xform( 1.0 ); // start off with identity
xform.translate( 1, 2, 3 );
xform.scale( 2, 2, 2 );
p *= xform;
// or in the reverse order ...
UT_Matrix4 xform( 1.0 ); // start off with identity
xform.prescale( 2, 2, 2 );
xform.pretranslate( 1, 2, 3 );
p *= xform;

Edited by edward
Corrected implications.
Link to comment
Share on other sites

  • 9 years 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...