rich_lord Posted February 28, 2016 Share Posted February 28, 2016 Hello. Trying to work on some Houdini math stuff and I've stumbled upon this problem. I have a point at {0,1,0} in world space. I've created an orient attribute for this point which is not aligned to the world axis. How do I convert this point position to the coordinate system represented by the orient attribute? I was hoping to write some VEX in a point wrangle to solve this for me, but I'm totally stumped Thanks for any insight! hou_axis.hip Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 28, 2016 Share Posted February 28, 2016 (edited) pos = qrotate(qinvert(orient), pos); pos *= invert(qconvert(orient)); Normalize matrix's axes, before all. You also can use the matrix directly: pos *= invert(r); custom_space.hipnc Edited February 28, 2016 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted February 28, 2016 Author Share Posted February 28, 2016 This is really useful f1480187! I tried to simplify the file a bit, to extract just the bit I need. I removed the origin point from your example, and it still seemed to give me the same results, so I assume the quaternion represents just a rotation, and there is no positional information contained in it. So I think all I need in the point wrangle is @P = qrotate(qinvert(p@orient), @P); I hope this hasn't left any edge cases open, as I confess I don't completely understand whats going on. Thanks so much for looking at this! Heres my updated file. custom_space_02.hipnc Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 29, 2016 Share Posted February 29, 2016 In cases you want to transform many attributes at once, including normals and orient itself, use Deformation Wrangle, modifying pos variable instead of @P. I assume the quaternion represents just a rotation, and there is no positional information contained in it Right, they are equivalents for 3 x 3 rotation matrices. To understand it more, you probably should use rotation matrix instead, building it from "raw" vectors without any cross products and normalizing. They are more intuitive, and operations are similar. To rotate something by matrix, simply multiply it with matrix, to transform something into matrix's space, multiply it by matrix's inverse. You will see how points transform in world space with respect to the custom basis. After that, you may remember that world's XYZ-space is an identity matrix {{1,0,0}, {0,1,0}, {0,0,1}}. Nothing will happen when you try to transform points from custom space into world space. Any point in viewport is already in it's place with respect to world's axes. The intuition is simple - viewport draw all things in one space, that why same point represented in different spaces is actually transforming: it has different numerical values in viewport's "world" space. So, point {1, 1, 1} in some skewed space may appear like {0.123, 123.0, 3000000.0} in world space. To get it back into world's {1, 1, 1}, multiply it with matrix. Building test scenes is the only good way to understand it deeply. 2 Quote Link to comment Share on other sites More sharing options...
rich_lord Posted February 29, 2016 Author Share Posted February 29, 2016 That is the most helpful post f1480187! Its much clearer now. I had not come across the deformation wrange before. 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.