views:

107

answers:

1

I have a sensor with 6 degree of freedom 3 axiz x,y,z and 3 angles yaw, pitch and roll. 3 axis distance is simple using distance formula but how to calculate 3 angular distances? Can anyone here please help me ???

+2  A: 

Yaw, pitch, and roll represent a set of Euler angles that specify a rotation from one coordinate system, XYZ, into another, X'Y'Z' . This transformation can also be expressed as a single rotation about an arbitrary axis. If I understand your question correctly, you want to know what this single rotation angle is.

It is possible to convert a set of Euler angles into a four-element structure called a quaternion.

q4 = cos(yaw/2) cos(pitch/2) cos(roll/2) + sin(yaw/2) sin(pitch/2) sin(roll/2)

q1 = cos(yaw/2) cos(pitch/2) sin(roll/2) - sin(yaw/2) sin(pitch/2) cos(roll/2)

q2 = cos(yaw/2) sin(pitch/2) cos(roll/2) + sin(yaw/2) cos(pitch/2) sin(roll/2)

q3 = sin(yaw/2) cos(pitch/2) cos(roll/2) - cos(yaw/2) sin(pitch/2) sin(roll/2)

(Source: http://www.resonancepub.com/quaterni.htm)

Once you have the quaternion, the rotation axis and rotation angle are easily calculated from the quaternion components. Using the above author's notation,

q = [q4 q1 q2 q2]

q4 = cos(theta/2)

q1 = sin(theta/2)A

q2 = sin(theta/2)B

q3 = sin(theta/2)C

where [A B C] is a vector in the XYZ system specifying the rotation axis, and theta is the rotation angle you're looking for.

So theta = 2*acos(q4)

Jim Lewis