Jump to content

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


ikoon

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

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

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