Jump to content

Rotate orient around velocity vector


sadboy

Recommended Posts

Does anyone know how to rotate an object around its velocity vector while it is still pointing into the direction of its velocity in vex? Maybe it is easier in vops, but it would help me understand better the underlying math behind it with vex.

Link to comment
Share on other sites

Well, if you have just the @v and @up, it's not the most ideal to create a spinning around v axis, because the orientation tends to get wonky when the v vector gets near the up vector. Either way, here's a poor man's setup I use:
 

//This method may result in fast flipping if the particles do loop-de-loops

//v@up = {0,1,0};//set this if you don't already have an up attribute
vector forward = normalize(v@v);

//create a quaternion rotating about the forward axis over time
vector4 rotQuat = quaternion(@Time*10, forward);

//use qrotate to rotate a vector by the quaternion
v@up = qrotate(rotQuat, v@up);


Using @orient is better because you don't have to worry about zero velocity situations or up vectors, but it requires some extra setup during the sim process (Assuming it's POPs)
 

Edited by dandeentremont
simplified code
  • Like 1
Link to comment
Share on other sites

thank you dan and ultraman. I am using @orient.

I ended up using a matrix rotate (in vops) along the velocity vector with a random rotation per id, then converting it to a quaternion. The vex approach you posted makes a little bit more sense. Im going to give it a try! I need to brush up on my linear algebra lol.

thank you so much again!

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