Hi,
I am using the Rigid Body toolkit. I have exported my data to an Excel spreadsheet and am attempting to process the data. As I understand the spreadsheet, it appears that 7 data points are returned for a given rigid body in a given frame. These data points are, in order, x,y,z,dx,dy,dz,dw.
My understanding of quaternions is that they define a vector in the global coordinate system about which the plane defined by the rigid body rotates by an amount dw. If this is so, then does each quaternion in the data describe the movement of the plane from the same frame as it rotates to the position in the next frame? If this is the case, then one should be able to use the x,y,z,dx,dy,dz,dw information from one frame to calculate the x,y,z data for the following frame, correct? Unfortunately, my calculation is not giving me the predicted value so I must be doing something wrong. If anyone has any suggestions, they will be much appreciated.
Quaternions
Re: Quaternions
The 7 values for each rigid body define it's position and orientation in the global coordinate system. The Quaternions have been a bit confusing for some users so the next version of the Rigid Body Tool will also output yaw, pitch, and roll values for each rigid body.
In the mean time, here's a function that can will convert the quaternions to Euler angles. Hopefully this will help you:
In the mean time, here's a function that can will convert the quaternions to Euler angles. Hopefully this will help you:
Code: Select all
void GetEulers(float qx, float qy, float qz, float qw, float *angle1,float *angle2, float *angle3)
{
float &heading = *angle1;
float &attitude = *angle2;
float &bank = *angle3;
double test = qx*qy + qz*qw;
if (test > 0.499) { // singularity at north pole
heading = (float) 2.0f * atan2(qx,qw);
attitude = 3.14159265f/2.0f;
bank = 0;
RadiansToDegrees(&heading);
RadiansToDegrees(&attitude);
RadiansToDegrees(&bank);
return;
}
if (test < 0.499) { // singularity at south pole
heading = (float) 2.0f * atan2(qx,qw);
attitude =  3.14159265f/2.0f;
bank = 0;
RadiansToDegrees(&heading);
RadiansToDegrees(&attitude);
RadiansToDegrees(&bank);
return;
}
double sqx = qx*qx;
double sqy = qy*qy;
double sqz = qz*qz;
heading = (float) atan2((double)2.0*qy*qw2.0*qx*qz , (double)1  2.0*sqy  2.0*sqz);
attitude = (float)asin(2.0*test);
bank = (float) atan2((double)2.0*qx*qw2.0*qy*qz , (double)1.0  2.0*sqx  2.0*sqz);
RadiansToDegrees(&heading);
RadiansToDegrees(&attitude);
RadiansToDegrees(&bank);
}
inline void RadiansToDegrees(float *value)
{
*value = (*value)*(180.0f/3.14159265f);
}
Re: Quaternions
Thanks for the code. I may end up using it. But, if I end up sticking with quaternions...
Does a quaternion in the output data define a rotation from the previous frame? Or does a quaternion from the output data define a rotation from the initial frame?
Thanks.
Does a quaternion in the output data define a rotation from the previous frame? Or does a quaternion from the output data define a rotation from the initial frame?
Thanks.
Re: Quaternions
In addition to my previous question, I am also curious whether there is a way to extract the x,y,z data for each marker in a rigid body. I know the output file provides x,y,z data for every marker seen by the camera, but this does not seem to be organized by rigid body. Any suggestions would be appreciated.
Thanks again.
Thanks again.
Re: Quaternions
Hi,
I am a confused about this topic.
In this function, what are the variable names for the euler angles?
In my understanding euler angles are pitch roll and yaw. So why would you use heading, attitude and bank variable names? or is heading=pitch, attitude = roll and bank=yaw?
Also, you wrote that in the next rigid body version, you will also output yaw, pitch , and roll. In the latest version, you output heading, attitude and bank. How does that fit in this topic?
Thanks for your help in advance.
I am a confused about this topic.
In this function, what are the variable names for the euler angles?
In my understanding euler angles are pitch roll and yaw. So why would you use heading, attitude and bank variable names? or is heading=pitch, attitude = roll and bank=yaw?
Also, you wrote that in the next rigid body version, you will also output yaw, pitch , and roll. In the latest version, you output heading, attitude and bank. How does that fit in this topic?
Thanks for your help in advance.
Re: Quaternions
I apologize for the confusion: heading = yaw, attitude = pitch, bank = roll. I'll get the naming cleared up in the future. I believe that the exporting of heading,attitude, and bank are in the current version. I'll update the code to standardize on yaw, pitch, roll everywhere to clear up the confusion.

 Posts: 5
 Joined: Thu May 28, 2009 4:41 am
Re: Quaternions
I am experiencing some difficulties with this codeexample.
It seems the qx, qy, qz, qw values that ARENA outputs aren't normalized..
(1.9743, 1.9957, 1.5598, 1.0126)
Do you know the max values of the quaternions ? 2 ? Than is it a matter of dividing the values by 2 ?
Thanks,
Keez
It seems the qx, qy, qz, qw values that ARENA outputs aren't normalized..
(1.9743, 1.9957, 1.5598, 1.0126)
Do you know the max values of the quaternions ? 2 ? Than is it a matter of dividing the values by 2 ?
Thanks,
Keez
Re: Quaternions
Quaternions streamed from Arena via NatNet are normalized. Can you post your code how you are getting those values?

 Posts: 5
 Joined: Thu May 28, 2009 4:41 am
Re: Quaternions
I am using a natnet to osc conversion program made by IPEM ghent. I'll ask them if it is a 1:1 conversion.
I guessed so.
ps
Will a new version of Arena output yaw, pitch, and roll values for each rigid body just like rigid body tool ?
I guessed so.
ps
Will a new version of Arena output yaw, pitch, and roll values for each rigid body just like rigid body tool ?