Alexey Vanzhula Posted August 13, 2015 Share Posted August 13, 2015 (edited) Hi. I`m looking for a python equivalent to morient expression function Edited August 13, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 13, 2015 Share Posted August 13, 2015 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 Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 13, 2015 Author Share Posted August 13, 2015 (edited) 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 August 13, 2015 by Alexey Vanzhula Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 13, 2015 Share Posted August 13, 2015 You could do euler = matrix3(vector1, vector2, vector3).extractRotates() That should give you world space to your vectors' space, in Euler angles. Quote Link to comment Share on other sites More sharing options...
Alexey Vanzhula Posted August 13, 2015 Author Share Posted August 13, 2015 Thanx 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.