Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


rotate with vex around axis next to the object


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 ?


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
2 people like this

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