hopbin9 Posted July 22, 2011 Share Posted July 22, 2011 Hi, In hscript there is the mlookat and mlookatup commands to compute a rotation between two vectors. How can this be done in Python? Right now, I'm doing something like this. str_n = "vector3"+pNormal.__str__().replace("[","(").replace("]",")") r1 = hou.Matrix4(hou.Matrix3(hou.hscriptExpression("mlookat("+str_n+",vector3(0,1,0))"))) But, there has to be a better way. Quote Link to comment Share on other sites More sharing options...
graham Posted July 22, 2011 Share Posted July 22, 2011 http://www.sidefx.com/docs/houdini11.0/hom/hou/Vector3#matrixToRotateTo Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted July 22, 2011 Author Share Posted July 22, 2011 http://www.sidefx.co...atrixToRotateTo Thank you! Never thought of looking at vector3. Quote Link to comment Share on other sites More sharing options...
graham Posted July 22, 2011 Share Posted July 22, 2011 I should also mention that it is quite easily to compute yourself: angle = v1.angleTo(v2) axis = v1.cross(v2) rot_xform = hou.hmath.buildRotateAboutAxis(axis, angle) Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted July 22, 2011 Author Share Posted July 22, 2011 Is there a way to calculate it with an UP vector? 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.