2

I'm developing an augmented reality application using the ARToolkit. I would like to add a feature where I would control an object's size, or control the volume of a played song, by rotating a specific marker. I've found an example of an application, which is returning a 4x4 matrix that contains position and rotation information of the marker.

An example of such a matrix:

 000,1878 -000,9442 -000,2707 -002,2898
 -000,6210  000,0994 -000,7775  117,8998
 -000,7610 -000,3141  000,5677 -530,6667
 000,0000  000,0000  000,0000  001,0000

I've found a formula and a corresponding java method for the decomposition of the matrix to all three rotation angles, but I'm confused by the returned angle values.

The java method:

/** this conversion uses conventions as described on page:
*   http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm
*   Coordinate System: right hand
*   Positive angle: right hand
*   Order of euler angles: heading first, then attitude, then bank
*   matrix row column ordering:
*   [m00 m01 m02]
*   [m10 m11 m12]
*   [m20 m21 m22]*/

public final void rotate(matrix  m) {
    // Assuming the angles are in radians.
    if (m.m10 > 0.998) { // singularity at north pole
        heading = Math.atan2(m.m02,m.m22);
        attitude = Math.PI/2;
        bank = 0;
        return;
    }
    if (m.m10 < -0.998) { // singularity at south pole
        heading = Math.atan2(m.m02,m.m22);
        attitude = -Math.PI/2;
        bank = 0;
        return;
    }
    heading = Math.atan2(-m.m20,m.m00);
    bank = Math.atan2(-m.m12,m.m11);
    attitude = Math.asin(m.m10);
    }

Example of the returned values:

Heading: 1.384716377951241, 
Bank: 1.3919044985590532
Attitude: -0.7751361901097762

So the result, obviously, isn't in degrees, which I would want. I'm I doing this the right way? What am I doing wrong?

TheAptKid
  • 1,559
  • 3
  • 25
  • 47
  • 1
    the results are in radians (http://en.wikipedia.org/wiki/Radian). To convert to degrees: Heading (deg) = (180/PI) * 1.384716377951241 = ~79deg. The same for the other two angles – Traian May 12 '14 at 08:20

0 Answers0