Jump to content

point position converted to different co-ordinate system.


rich_lord

Recommended Posts

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!

 

 

 

 

post-7586-0-86807900-1456685908_thumb.jp

hou_axis.hip

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

  • Like 2
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...