Jump to content

rotate with vex around axis next to the object


jon3de

Recommended Posts

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
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...