Matrx transpose and normal multiplication?

   6671   4   2
User Avatar
Member
88 posts
Joined: March 2010
Offline
Hi

I was going through the documentation and I see that to multiply the normals with a matrix, one needs to invert and transpose it first. That does not sound like the case for the point vectors(P). At least based on what I see in the examples.


p * m # to transform the point
v * m # to transform the vector
n * m.inverted().transposed() # to transform the normal
# (note that m.inverted().transposed() is mathematically equivalent to m.transposed().inverted())

http://www.sidefx.com/docs/houdini11.0/hom/hou/Matrix4 [sidefx.com]

In that page there is also a “note” (at the top of the page) about transposing the matrices and using the reverse order for the multiplication. So am I supposed to transpose the matrices when multiplying with any vector or only vectors that involve normals?

thanks
User Avatar
Member
8573 posts
Joined: July 2007
Online
to put it more simply

vector * matrix will transform the vector by the whole matrix so it will translate rotate and scale that vector
this you probably want to happen by default for P

vector * matrix inverted transposed will just rotate the vector and scale by inverse scale values despite of translation values of the matrix
this you want to generally happen with N
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
88 posts
Joined: March 2010
Offline
tamte,

Awesome answer. Thank you
User Avatar
Member
8573 posts
Joined: July 2007
Online
and to that ‘note’
in Houdini you just use matrices as they are with C*B*A order (presuming they are row based)

but because of matrices in H are row based and A, B, C in that ‘note’ are column based you need to transpose them first to get Houdini equivalent ones then perform C'*B'*A'
but if you have never met column based matrices and you are used to row based like in Houdini or Softimage it may seem a little confusing but for TD used to column based it may be useful info
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
129 posts
Joined: Sept. 2021
Offline
tamte
and to that 'note'
in Houdini you just use matrices as they are with C*B*A order (presuming they are row based)

but because of matrices in H are row based and A, B, C in that 'note' are column based you need to transpose them first to get Houdini equivalent ones then perform C'*B'*A'
but if you have never met column based matrices and you are used to row based like in Houdini or Softimage it may seem a little confusing but for TD used to column based it may be useful info

Yeah, I was doing some testing and all the matrices seem to be transposed from what I'm used to in traditional math...

float x_translation = chf("x_translation");
float y_translation = chf("y_translation");
float z_translation = chf("z_translation");
// This didn't work
// matrix transformation = set(
//     set(1,0,0,x_translation),
//     set(0,1,0,y_translation),
//     set(0,0,1,z_translation),
//     set(0, 0, 0, 1)
// );

// This one works:
// matrix transformation = set(
//     set(1, 0, 0, 0),
//     set(0, 1, 0, 0),
//     set(0, 0, 1, 0),
//     set(x_translation, y_translation, z_translation, 1)
// );

// This one also works:
matrix transformation = set(
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    x_translation, y_translation, z_translation, 1
);

v@P = v@P * transformation;
// Interestingly, this is equivalent to:
// v@P = transformation * v@P;
// and:
// v@P *= transformation;

// The documentation says that matrices are row major, but it seems that the matrices that work are transposed from matrices we'd see in traditional math.

I have two questions:
  1. Why are these matrices transposed like this?
  2. Why does the multiplication order not matter?

Thanks!
  • Quick Links