Google cardBoard Android API (十二):HeadTransform

来源:互联网 发布:highlight.js下载 编辑:程序博客网 时间:2024/05/29 02:58
public class HeadTransform

Describes the head transform independently of any eye parameters.

Public Constructors

HeadTransform()

Public Methods

void
getEulerAngles(float[] eulerAngles, int offset)
void
getForwardVector(float[] forward, int offset)
void
getHeadView(float[] headView, int offset)
void
getQuaternion(float[] quaternion, int offset)
void
getRightVector(float[] right, int offset)
void
getTranslation(float[] translation, int offset)
void
getUpVector(float[] up, int offset)

Inherited Methods

Public Constructors

public HeadTransform ()

Public Methods

public void getEulerAngles (float[] eulerAngles, int offset)

Provides the Euler angles representation of the head rotation.

Use of Euler angles is discouraged as they might be subject to Gimbal lock situations. Use quaternions or rotation matrices instead whenever possible.

The provided values represent the viewport rotation as pitch, yaw and roll angles where the matrix R = Rz(roll) * Rx(pitch) * Ry(yaw) represents the full rotation. This rotation matrix order ensures both yaw and roll are in the full [-pi, pi] interval.

The angles are provided in radians, in this order and within the following intervals:

  • Pitch (X axis): [-pi/2, pi/2]
  • Yaw (Y axis): [-pi, pi]
  • Roll (Z axis): [-pi, pi]

The X-Y-Z axes are the basis of a right-handed OpenGL-style coordinate system. During Gimbal lock this method enforces yaw to 0 and provides a valid roll angle.

Parameters
eulerAnglesArray where the 3 angles will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getForwardVector (float[] forward, int offset)

Provides the direction the head is looking towards as a 3x1 unit vector.

Note that in OpenGL the forward vector points into the -Z direction. Make sure to invert it if ever used to compute the basis of a right-handed system.

Parameters
forwardArray where the forward vector will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getHeadView (float[] headView, int offset)

A matrix representing the transform from the camera to the head.

Head origin is defined as the center point between the two eyes.

Parameters
headViewArray where the 4x4 column-major transformation matrix will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getQuaternion (float[] quaternion, int offset)

Provides the quaternion representing the head rotation.

Parameters
quaternionArray where the quaternion (x, y, z, w) will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getRightVector (float[] right, int offset)

Provides the rightwards direction of the head as a 3x1 unit vector.

Parameters
rightArray where the right vector will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getTranslation (float[] translation, int offset)

Provides the relative translation of the head as a 3x1 vector.

Parameters
translationArray where the translation vector will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.

public void getUpVector (float[] up, int offset)

Provides the upwards direction of the head as a 3x1 unit vector.

Parameters
upArray where the up vector will be written to.offsetOffset in the array where data should be written.
Throws
IllegalArgumentExceptionIf there is not enough space to write the result.
0 0