Jump to content
catchyid

Quaternion questions

Recommended Posts

Hi,

using vex...

a) First Question

float angle = radians(90);

vector axis = {just random vector}

vector4 goalQuaternion = quaternion(angle,normalize(axis));

Question: IF angle == 0.0, then is this a valid quaternion? I don't want to spin, so I am setting angle to zero, however when I do that, I don't get any rotation?

b ) Second question

if I have two quaternions:

vector4 Q_Init, Q_Dest; {they get initialized correctly}

vector4 Q_Diff =  qmultiply(Q_Init,qinvert(Q_Dest); //difference between two quaternions

My question:If I want to interpolate from init to dest quaternions in 10 steps, how do I do that? meaning If I multiply Q_Init by Q_Diff I will jump at once, but I want to that in 10 steps instead, it's like dividing Q_Diff by "10"

 

Thanks

Share this post


Link to post
Share on other sites

a) if the angle is 0, you will get identity quaternion {0,0,0,1} so no rotation

as the angle/axis notation defines quaternion as a rotation of angle degrees around the axis, if the angle is 0, then the rotation around given axis is 0 and hence no rotation

b) 

vector4 Q_Init = eulertoquaternion(radians(chv("q0")), 0);
vector4 Q_Dest = eulertoquaternion(radians(chv("q1")), 0);


vector4 Q_Diff =  qmultiply(Q_Dest,qinvert(Q_Init)); // quaternion difference from Q_Init to Q_Dest

int nsteps = chi("nsteps");
Q_Diff = slerp({0,0,0,1},Q_Diff, 1.0/nsteps); // compute Q_Diff rotation for single step

p@orient = Q_Init;
for (int i=0;i<nsteps;i++){
    p@orient = qmultiply(Q_Diff, p@orient);
}
// after adding Q_Diff nsteps times to Q_Init p@orient will result in Q_Dest 

 

  • 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

×