morn66 Posted September 19, 2019 Share Posted September 19, 2019 Hi everyone, With VEX, I try to rotate a point around the closest point of a curve. It seems to work for the rotation but the axis is off! I have no idea how to fix that. here is the file Vex_pointRotateAroundCurveAxis.hiplc Quote Link to comment Share on other sites More sharing options...
LucaScheller Posted September 19, 2019 Share Posted September 19, 2019 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 2 Quote Link to comment Share on other sites More sharing options...
morn66 Posted September 19, 2019 Author Share Posted September 19, 2019 Oh wow! That works perfectly! Thanks for all the explanations! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.