Jump to content
ikoon

non-uniform scaling in the direction of arbitrary vector, packed primitives (make transform, pivot rotation?)

Recommended Posts

As in the picture below, I have partially succeeded ( R * S * R-1 ) .
But I would really like to scale in arbitrary vector's direction, probably with "pivot rotation"? I did not succeed to make pr work:

http://www.sidefx.com/docs/houdini/vex/functions/maketransform.html

 

My solution so far, also attached in the hip file:

axes.PNG.d4f02e245cee95b66959be03c53493d6.PNG

matrix pft = primintrinsic(0,"packedfulltransform",@primnum);
matrix3 transform = primintrinsic(0, "transform", @primnum);

// reset rotation
vector rotate = cracktransform(0, 0, 1 , {0,0,0}, pft);
matrix rotatemat = maketransform(0, 0, {0,0,0}, rotate, {1,1,1}, @P);
rotatemat = invert(rotatemat);
transform *= matrix3(rotatemat);

// scale
vector scale = {0.1,0.1,2}; // non uniform scale
matrix scalemat = maketransform(0, 0, {0,0,0}, {0,0,0}, scale, @P);
transform *= matrix3(scalemat);

// restore rotation
rotatemat = invert(rotatemat);
transform *= matrix3(rotatemat);

setprimintrinsic(0, "transform", @primnum, transform);

 

xyz - v03 - odforce.hiplc

Share this post


Link to post
Share on other sites

Like this?

vector scale = chv("scale");
vector axis = chv("axis");

matrix3 oriented_space = dihedral({0,1,0}, normalize(axis));

matrix3 transform = primintrinsic(0, "transform", @primnum);

transform *= invert(oriented_space);
scale(transform, scale);
transform *= oriented_space;

setprimintrinsic(0, "transform", @primnum, transform);

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you very much F1! This works great.

I just thought, that the "pivot rotatation (pr)" argument of maketransform() can solve this without RSR-1. I thought, that pr rotates the pivot, so the scale is then oriented. But pr is maybe just a position of the rotation centre? It is not described in the documentation.

Share this post


Link to post
Share on other sites
Quote

Objects and geometry nodes now have a separate Pivot Rotate parameter to rotate the geometry’s local axes. Previously, it was only possible to translate the local axes. Rotating the local frame of reference can make it easier to animate along non-axis-aligned directions.

The interactive pivot handle now allows rotation as well as translation. (Press Ins or ' to switch to the pivot handle.)

It was added everywhere with transform available. You can test it with Transform SOP. It does rotate transform space. It is simple layering concept (you can have pivot for pivot and so on), but not intuitive and the argument probably expects Euler angles. For me it is not worth to deal with (in VEX), since I can always layer another matrix.

  • Thanks 1

Share this post


Link to post
Share on other sites

Ooh I see! Thank you very very much. I will stick to your vex solution and practice that.

edit: BTW my initial solution contains unnecessary scalemat, your scale() function is much better, thank you.

Edited by ikoon

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

×