# problems with clipSOP and rotateVOP

11 replies to this topic

### #1 Ezz

Ezz

Initiate

• Members
• 236 posts
• Joined: 23-February 05
• Name:Erik Egsgaard Nielsen

Posted 14 June 2012 - 12:39 PM

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.

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

### #2 Rudinie

Rudinie

Initiate

• Members
• 105 posts
• Joined: 24-April 08
• Location:Netherlands
• Name:rudi Nieuwenhuis

Posted 25 June 2012 - 08:01 AM

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

### #3 old school

old school

Houdini Master

• Members
• 888 posts
• Joined: 21-March 03
• Location:The Great White North

Posted 25 June 2012 - 11:37 AM

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.

#### Attached Files

There's at least one school like the old school!

### #4 Rudinie

Rudinie

Initiate

• Members
• 105 posts
• Joined: 24-April 08
• Location:Netherlands
• Name:rudi Nieuwenhuis

Posted 25 June 2012 - 12:57 PM

old school, on 25 June 2012 - 11:37 AM, said:

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.

### #5 Ezz

Ezz

Initiate

• Members
• 236 posts
• Joined: 23-February 05
• Name:Erik Egsgaard Nielsen

Posted 28 June 2012 - 04:27 AM

Hi!

Great examples!!

Cheers

Erik

### #6 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 29 June 2012 - 01:26 PM

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

Edited by spev, 29 June 2012 - 01:26 PM.

### #7 old school

old school

Houdini Master

• Members
• 888 posts
• Joined: 21-March 03
• Location:The Great White North

Posted 30 June 2012 - 06:26 AM

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.

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.
There's at least one school like the old school!

### #8 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 30 June 2012 - 07:57 AM

.

Edited by spev, 30 June 2012 - 08:06 AM.

### #9 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 30 June 2012 - 07:59 AM

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.

### #10 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 30 June 2012 - 10:50 AM

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, 30 June 2012 - 10:57 AM.

### #11 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 30 June 2012 - 12:00 PM

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

### #12 spev

spev

Peon

• Members
• 59 posts
• Joined: 14-September 05

Posted 30 June 2012 - 12:01 PM

OOps need to actually attach the file blast the attach This file button!..

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users