Jump to content
morn66

VEX: Point rotate around curve axis

Recommended Posts

Hi Julien,

you need to first transform the point to its local coordinate space before applying the rotation. This is done via (@P-hit_P), then you apply the matrix and finally restore the transform to the world position by adding hit_P again.

vector @P;

// Get the nearest hit attributes
int hit_prim_id = -1;
vector hit_prim_uv;
xyzdist(1,@P,hit_prim_id,hit_prim_uv);
vector hit_P = primuv(1,"P",hit_prim_id,hit_prim_uv);
vector hit_N = normalize(primuv(1,"N",hit_prim_id,hit_prim_uv));

// Rotate around the nearest hit point
matrix m = ident();
float angle = radians(ch('amount'));
rotate(m, angle, hit_N);
@P = (@P-hit_P) * m + hit_P;

 

I've gone ahead and updated your file. I've also switched to the xyzdist() instead of nearpoint() function to always get a smoothly interpolated Position and Normal.

If you have further questions let me know :)

Cheers,

Luca

 

 

Vex_pointRotateAroundCurveAxisFixed.hiplc

  • Thanks 1

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

×