Jump to content

Quaternion questions


catchyid

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

Link to comment
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
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...