Jump to content

morient in python


Recommended Posts

You would most likely have to build the matrix yourself, fortunately if you already have two axes, as I assume you do to use the morient expression, although I've never used so it I'm not hundred percent on use cases, it shouldn't be too tough.

 

All you need to do is take the cross product of the two axis vectors which will then give you the third axis and you can build the matrix per component hou.matrix3(X[0], X[1], X[2], Y[0].....,Z[2]).. Houdini uses Row major notation so that should be the proper way to build it.

 

This page seemed to be good as well http://renderdan.blogspot.com/2006/05/rotation-matrix-from-axis-vectors.html

Link to comment
Share on other sites

Thanx !

I have 3 perpendicular vectors and I want to get rotation to that "axis system".
The most simple form to get it is using hou.hscriptVectorExpression to get 3 angles from morient expr.
So I just want to see most elegant (python) way )

EDIT:

x, y, z = hou.hscriptVectorExpression('''
{
matrix mat=morient(vector3(%f, %f, %f), vector3(%f, %f, %f));
return vector3(explodematrix( mat, "SRT", "XYZ", "RX" ), explodematrix( mat, "SRT", "XYZ", "RY" ), explodematrix( mat, "SRT", "XYZ", "RZ" ));
}''' % (dir_y[0], dir_y[1], dir_y[2], dir_z[0],dir_z[1],dir_z[2]) )
Edited by Alexey Vanzhula
Link to comment
Share on other sites

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...