本文整理了Java中org.rajawali3d.math.Quaternion.getGimbalPole
方法的一些代码示例,展示了Quaternion.getGimbalPole
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quaternion.getGimbalPole
方法的具体详情如下:
包路径:org.rajawali3d.math.Quaternion
类名称:Quaternion
方法名:getGimbalPole
[英]Get the pole of the gimbal lock, if any. Requires that this Quaternion be normalized.
[中]获取万向节锁的杆(如果有)。要求对这个四元数进行规范化。
代码示例来源:origin: Rajawali/Rajawali
/**
* Gets the yaw angle from this {@link Quaternion}. This is defined as the rotation about the Y axis. Requires that
* this {@link Quaternion} be normalized.
*
* @return double The yaw angle in radians.
*
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getRotationY() {
return getGimbalPole() == 0 ? Math.atan2(2.0 * (y * w + x * z), 1.0 - 2.0 * (y * y + x * x)) : 0.0;
}
代码示例来源:origin: Rajawali/Rajawali
/**
* Gets the roll angle from this {@link Quaternion}. This is defined as the rotation about the Z axis. Requires that
* this {@link Quaternion} be normalized.
*
* @return double The roll angle in radians.
*
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getRotationZ() {
final int pole = getGimbalPole();
return pole == 0 ? Math.atan2(2.0 * (w * z + y * x), 1.0 - 2.0 * (x * x + z * z))
: pole * 2.0 * Math.atan2(y, w);
}
代码示例来源:origin: Rajawali/Rajawali
/**
* Gets the pitch angle from this {@link Quaternion}. This is defined as the rotation about the X axis. Requires
* that this {@link Quaternion} be normalized.
*
* @return double The pitch angle in radians.
*
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getRotationX() {
final int pole = getGimbalPole();
return pole == 0 ? Math.asin(MathUtil.clamp(2.0 * (w * x - z * y), -1.0, 1.0)) : pole * MathUtil.PI * 0.5;
}
代码示例来源:origin: Rajawali/Rajawali
@Test
public void testGetGimbalPole() {
final Quaternion q = new Quaternion();
q.fromAngleAxis(Axis.X, 90);
assertEquals(q.getGimbalPole(), 0);
q.fromAngleAxis(Axis.X, 90).multiply((new Quaternion()).fromAngleAxis(Axis.Y, 90));
assertEquals(q.getGimbalPole(), 1);
q.fromAngleAxis(Axis.X, 90).multiply((new Quaternion()).fromAngleAxis(Axis.Y, -90));
assertEquals(q.getGimbalPole(), -1);
}
代码示例来源:origin: pondurii/vrVideo
/**
* Gets the roll angle from this {@link Quaternion}. This is defined as the rotation about the Z axis.
*
* @return double The roll angle in radians.
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getRoll() {
normalize();
final int pole = getGimbalPole();
return pole == 0 ? Math.atan2(2.0 * (w * z + y * x), 1.0 - 2.0 * (x * x + z * z)) : pole * 2.0 * Math.atan2(y, w);
}
代码示例来源:origin: pondurii/vrVideo
/**
* Gets the yaw angle from this {@link Quaternion}. This is defined as the rotation about the Y axis.
*
* @return double The yaw angle in radians.
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getYaw() {
normalize();
return getGimbalPole() == 0 ? Math.atan2(2.0 * (y * w + x * z), 1.0 - 2.0 * (y * y + x * x)) : 0.0;
}
代码示例来源:origin: pondurii/vrVideo
/**
* Gets the pitch angle from this {@link Quaternion}. This is defined as the rotation about the X axis.
*
* @return double The pitch angle in radians.
* @see <a href="https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java">
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Quaternion.java</a>
*/
public double getPitch() {
normalize();
final int pole = getGimbalPole();
return pole == 0 ? Math.asin(MathUtil.clamp(2.0 * (w * x - z * y), -1.0, 1.0)) : pole * MathUtil.PI * 0.5;
}
内容来源于网络,如有侵权,请联系作者删除!