Jump to content

Trouble with rotation matrix math / extracting a transform rotation pivot


Recommended Posts

My whole end goal is essentially just trying to take a Transform SOP's pivot rotation (visually shown in the viewport as the transform pivot handle) and extract it as a vector. This way I can then apply this rotation pivot vector to future transform SOPs to effectively copy the rotation pivot across. Note that I'm not talking about the rotation of the geometry, I'm talking about the pivot since I've already figured out the geometry rotation successfully.

At first this sounds simple but, unless I've gone down the wrong path, it seems to be very difficult. This is because the pivot's rotation is affected by three different parameters in the Transform SOP.

When you rotate with the Transform SOP, it has three different vector parms to enter rotation data for: pre-rotate, pivot rotate, and rotate. If you play around with them, you'll realize the node combines them in order like this: pre-rotate --> pivot rotate --> rotate. The resulting rotation is then applied to the geometry/pivot.

That's all handy dandy and all. But I for the life of me can't get my VEX to mimic this behavior using matrix math. This is down to that pesky order in which rotations are combined. Currently my logic is to relative reference the 3 rotation parms into a detail wrangle, convert them to matrices, multiply them with eachother in the order explained above, then finally convert the resulting matrix back into a euler vector. But rotating some geo with this new vector shows an incorrect rotation in certain cases (again, all down to the order in which the rots are used). I can tell its incorrect since I'm just doing a direct comparison of the viewport handle I'm calculating (visualized on a Transform SOP) to a second Transform SOP that's being used as my ground truth.

Basically after studying transform matrices and how to combine them for rotation calculations I'm getting stuck in this instance and I simply can't figure this out anymore (my brain is too small). But maybe there's just a simpler way to extract the euler rotation of the pivot handle.

Can anyone give me any ideas, or even better some simple working solution/VEX for this problem that I can go off of? Much appreciated, thanks everyone.

Link to comment
Share on other sites

On 2/9/2025 at 8:39 PM, viability9 said:

My whole end goal is essentially just trying to take a Transform SOP's pivot rotation (visually shown in the viewport as the transform pivot handle) and extract it as a vector. This way I can then apply this rotation pivot vector to future transform SOPs to effectively copy the rotation pivot across. Note that I'm not talking about the rotation of the geometry, I'm talking about the pivot since I've already figured out the geometry rotation successfully.

At first this sounds simple but, unless I've gone down the wrong path, it seems to be very difficult. This is because the pivot's rotation is affected by three different parameters in the Transform SOP.

When you rotate with the Transform SOP, it has three different vector parms to enter rotation data for: pre-rotate, pivot rotate, and rotate. If you play around with them, you'll realize the node combines them in order like this: pre-rotate --> pivot rotate --> rotate. The resulting rotation is then applied to the geometry/pivot.

That's all handy dandy and all. But I for the life of me can't get my VEX to mimic this behavior using matrix math. This is down to that pesky order in which rotations are combined. Currently my logic is to relative reference the 3 rotation parms into a detail wrangle, convert them to matrices, multiply them with eachother in the order explained above, then finally convert the resulting matrix back into a euler vector. But rotating some geo with this new vector shows an incorrect rotation in certain cases (again, all down to the order in which the rots are used). I can tell its incorrect since I'm just doing a direct comparison of the viewport handle I'm calculating (visualized on a Transform SOP) to a second Transform SOP that's being used as my ground truth.

Basically after studying transform matrices and how to combine them for rotation calculations I'm getting stuck in this instance and I simply can't figure this out anymore (my brain is too small). But maybe there's just a simpler way to extract the euler rotation of the pivot handle.

Can anyone give me any ideas, or even better some simple working solution/VEX for this problem that I can go off of? Much appreciated, thanks everyone.

Can you instead post a minimal example of what you're actually trying to achieve ?

At the end of the day, a transform (in Transform SOP) is a concatenation of several simpler (as in: human readable) 4x4 homogeneous matrices, yes 4 by 4, because we need translates; I can't explain in a reply on a forum.

First you should be somehow comfortable with homogeneous matrices;

Things you should look up and be really comfortable with:

Storing the transform in Transform SOP (check output Attribute, xform (post multiply)

Restoring that transform with a Match Size -> Restore XForm 

Inverse a transform

Copy Transforms between geometries -- beware they are stored in detail  -- You can store them in prim, but then you have to do it yourself in PrimWrangle  

CrackTransform (VEX)

look at the transform in Geometry SpreadSheet in Decompose Matrices  (this in in View menu/ 4th checkbox), this will help you understand what exactly you're looking to extract

As an example of a workflow that uses all of that and that I use all the time, you iterate over a bunch of objects, find their  oriented bounding box, Axis align the object, work on the object as if it was Axis aligned, and restore the object to its initial position. 

 

 

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