Jump to content

problems with clipSOP and rotateVOP


Ezz

Recommended Posts

Hi good folks.

I am doing some RND in my sparetime and I have given me the task of making some sort of a folding-OTL.

But I have allready bumped my head on the first opstical.

I have made this very simpel setup where I use a clipSop to make the initial fold - then I use a rotateVOP in a VOPSOP

to rotate the fold.

I have managed to pibe the right data from the clipSOP to the VOPSOP to rotate the fold in the right axis. Its a bit of a hack

and surely it can be more beautyfull/simple.

But I can not find a method to move the folds pivotpoint the right place, so it does not offset when I move the clip-tool.

I have tried to find a solution in the rotate-matrix, but with no luck.

Does anyone of you have a smart solution to this?

Any help would be much appriciated.

Cheers

Erik

folder_v001.hipnc

Link to comment
Share on other sites

  • 2 weeks later...

Hi Ezz,

What i've done is move the part that needs to be folded to the origin, then use your vopsop to rotate the points in it, and then move it back to it's original position.

Hardly an elegant solution because i'm pretty sure someone who is a bit more math-savvy then i am will be able to rotate around a point in the vopsop but at least it works.

You should however keep the distance in the clip at 0, or else you need to translate the points along the normal by that amount.

I need to get more acquainted with the math in this...

folder_v002.hipnc

Link to comment
Share on other sites

Rudinie, that is exactly how you apply a rotate or a scale to geometry: apply pivot translate (to origin), transform geometry (Translate+Rotate+Scale), apply inverse pivot translate. Done.

You are also correct in that the way you did it, it isn't as optimized as it could be. Best to do it all in VOPs and use many of the built-in VOP transformer matrix and vector nodes that take in a pivot point to do the work for you, and do it much faster.

Knowing that:

- a 4x4 matrix is generally used to hold a translate, rotate, scale and shear Transform in VOPs.

- a 3x3 matrix is generally used to hold a rotate Transform in VOPs.

- you can multiply a 3 float position (e.g.: P) by a 3x3 or 4x4 matrix to apply transformations to geometry P. Order is critical. P first then the matrices.

- you can multiply two 3x3, two 4x4 or a 3x3 by a 4x4 matrix to apply successive transforms. Then take P and multiply by the final matrix.

- there is nothing special about a 3x3 or 4x4 matrix other than they are real handy to hold geometric transformations efficiently.

See the attached example file.

folder_v003.hipnc

Link to comment
Share on other sites

Best to do it all in VOPs and use many of the built-in VOP transformer matrix and vector nodes that take in a pivot point to do the work for you, and do it much faster.

See the attached example file.

Thank you very much Jeff for taking the time to explain this with an example. Very much appreciated. I'm sure it will fill a void in many Houdini users' comprehension of matrices in vops, not just in mine.

Link to comment
Share on other sites

Hiya Guys...Jeff....Would you be so kind as to explain how to go the other way...returning the rotation angle please..in terms of vop nodes

Thanks in advance

Edited by spev
Link to comment
Share on other sites

The Extract Transform VOP can extract either one of translate, rotate or scale from a 4x4 matrix. This is how I extract the rotate out of the transform matrix in the example above.

If your question is given two different sets of the same geometry in different orientations and either has the same shape and topology, extract the rotate values. Well that isn't so straightforward but quite possible to do but since you don't have the advantage of the transform matrix that did the transform, you will run in to issues, especially if you wish to calculate the rotate with animated targets that roll more than 360 degrees (or 180). Solutions are prone to flipping about the 360 (and 180) degree values and this is to be expected. Whenever the two vectors are parallel regardless of where they start and end.

Having said all of that, it's actually pretty easy. For the cases where both sets of geometry are not deforming, you can take any point from the two sets of geometry, calculate their surface N normals, then in VOPs use the Align VOP (using the dihedral() function, wikipedia it or just accept it for what it does) and this generates a 3x3 matrix that holds the rotation to align the first vector to the second vector. Then use the Extract Transform VOP again to extract three Euler rotate values. The sweet part is that VOPs automatically type casts the 3x3 matrix to a 4x4 matrix correctly for you without having to insert a VOP to do it. Part of the Ease-Of-Use drive over the years.

As for the flipping case, what happens when the two vectors are perfectly parallel (dihedral returns 0) compared to when they are almost parallel on either side of perfect alignment. One will go from 0.0000001 to 0. The other from 359.9999 to 0. The latter gives you the flip and as you approach 0, the significant digits will easily exceed the precision available and that goes for doubles as well. Actually as you approach 0 from the 359 side of the equation, you reach infinity (indeterminate). Don't worry. I'm not asking for proofs. Just need to be aware of this. This is the same issue with look-ats and character kinematics and joint flipping. Yes you can use the Rotate VOP (dihedral()) to calculate look-at rotations.

folder_v004.hipnc

You could also construct a quaternion in a 4x4 matrix to do the rotates but even then it will still be prone to flipping around the point where your two vectors sweep through being parallel.

----

What do I do to remove this ambiguity? Do everything in Houdini why of course and keep everything procedural. ;)

----

Another way is to use CHOPs and works well for the case where the geometry is animated and deforming. Record your singe set of deforming animated geometry with a Geometry CHOP. You will calculate the transforms relative to the starting frame geometry position. This also includes transforms and rotates. You will see discontinuities in the rotate channels. Just append a Transform CHOP and this will properly accumulate the rotates and remove the discontinuities in the rotate channels. Export the rotates to wherever you want. At this point it's a toss as to what's faster: point() expression to extract rotates in to paris or CHOPs...

CHOPs also has ways of parsing vectors (t channels, r channels) and can do full matrix transforms if the t, r and s channels are there for every point. As usual, the matrices are handled for you so you just need to know that 4x4 matrices can hold Transforms. No magic what so ever.

That is what I would do if it was mission critical and live with the hit you take with CHOPs.

Link to comment
Share on other sites

wow jeff.thanks for the reply. I am no mathematician just a humble artist. I do understand especially the gimbal lock thingy. I thought about chops as is seemed a more intuitive way to go. I simplify my geo by making a triangle from center and 2 other points so chops should be quick. Thanks again and i may have to ask another p or too.

Link to comment
Share on other sites

Ahhh..My problem is I would like to get the transforms from objects that are non deforming but have different topologies..I am trying to make a fix for doing this in chops with heavy geo...Ie I make a triangle from the DOp's geo and manipulate the channels in chops as original geo to heavy...the problem is how to get the transforms back on to the highrez geo reliably....

This is as you suggeste JEff...to take the hit but for this project it is too much hence trying to make this workaround...

I could export from dops using the create points to represent objects and the orient attribute through a copy node to do what I want ....but what if we only have the bgeo sequence...I want to do recreate this same function of create points to represent objects and the orient attribute..

Ta

Edited by spev
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...