Jump to content
jon3de

rotate with vex around axis next to the object

Recommended Posts

hi,

I know how to do some basic rotations with vex although the objects is always rotation around itself. Is it possible to do the same thing but use an external rotation point e.g. one of the corners of the box ?

rotate_vex_question.jpg 

Share this post


Link to post
Share on other sites

And you can do more. Rotate along the vector defined by 2 specific points in full 3d:

// Points to define vector axis and center
vector P0 = point(0, "P", chi("p0_axis"));
vector P1 = point(0, "P", chi("p1_axis"));
vector axis = normalize(P1 - P0);
vector center = P1 - (P1 - P0) / 2;

// offset to center
vector _P = @P - center;
float ang = chf('angle');
vector4 q = quaternion(radians(ang), axis);

// rotate P and N
@P = qrotate(q, _P);
@N = normalize(qrotate(q, @N));

// replace to origin
@P += center;

 

Edited by fsimerey
Correction for center
  • Like 2

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

×