2

我正在使用 ARToolkit 开发增强现实应用程序。我想添加一个功能,通过旋转特定的标记来控制对象的大小或控制播放歌曲的音量。我找到了一个应用程序示例,它返回一个 4x4 矩阵,其中包含标记的位置和旋转信息。

这种矩阵的一个例子:

 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

我找到了将矩阵分解为所有三个旋转角度的公式相应的 java 方法,但我对返回的角度值感到困惑。

java方法:

/** 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);
    }

返回值示例:

Heading: 1.384716377951241, 
Bank: 1.3919044985590532
Attitude: -0.7751361901097762

因此,结果显然不是我想要的度数。我这样做对吗?我究竟做错了什么?

4

0 回答 0