Jump to content
Ezz

problems with clipSOP and rotateVOP

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hi!

Thank you very much for your answers. You have been very helpfull.

Great examples!!

Cheers

Erik

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Here is an example of what I want to do...it works as I mentioned above but I want to acheive the same effect from the cache node...Sorry to hijack this post.. :ph34r::D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×