This site has been permanently archived. The content on this site was last updated in 2019.
HeadTransform
Stay organized with collections
Save and categorize content based on your preferences.
Describes the head transform independently of any eye parameters.
Public Methods
void
|
getEulerAngles(float[] eulerAngles, int offset)
Provides the Euler angles representation of the head rotation.
|
void
|
getForwardVector(float[] forward, int offset)
Provides the direction the head is looking towards as a 3x1 unit vector.
|
void
|
getHeadView(float[] headView, int offset)
A matrix representing the transform from the camera to the head.
|
void
|
getQuaternion(float[] quaternion, int offset)
Provides the quaternion representing the head rotation.
|
void
|
getRightVector(float[] right, int offset)
Provides the rightwards direction of the head as a 3x1 unit vector.
|
void
|
getTranslation(float[] translation, int offset)
Provides the relative translation of the head as a 3x1 vector.
|
void
|
getUpVector(float[] up, int offset)
Provides the upwards direction of the head as a 3x1 unit vector.
|
Inherited Methods
From class
java.lang.Object
boolean
|
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
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
eulerAngles |
Array where the 3 angles will be written to. |
offset |
Offset in the array where data should be written. |
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
forward |
Array where the forward vector will be written to. |
offset |
Offset in the array where data should be written. |
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
headView |
Array where the 4x4 column-major transformation matrix will be written to. |
offset |
Offset in the array where data should be written. |
public
void
getQuaternion
(float[] quaternion, int offset)
Provides the quaternion representing the head rotation.
Parameters
quaternion |
Array where the quaternion (x, y, z, w) will be written to. |
offset |
Offset in the array where data should be written. |
public
void
getRightVector
(float[] right, int offset)
Provides the rightwards direction of the head as a 3x1 unit vector.
Parameters
right |
Array where the right vector will be written to. |
offset |
Offset in the array where data should be written. |
public
void
getTranslation
(float[] translation, int offset)
Provides the relative translation of the head as a 3x1 vector.
Parameters
translation |
Array where the translation vector will be written to. |
offset |
Offset in the array where data should be written. |
public
void
getUpVector
(float[] up, int offset)
Provides the upwards direction of the head as a 3x1 unit vector.
Parameters
up |
Array where the up vector will be written to. |
offset |
Offset in the array where data should be written. |
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003e\u003ccode\u003eHeadTransform\u003c/code\u003e describes the head's position and orientation in 3D space, independent of eye parameters.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to access head rotation as Euler angles, quaternion, and a 4x4 head view matrix.\u003c/p\u003e\n"],["\u003cp\u003eIt also provides methods to access the head's forward, right, up, and translation vectors as 3x1 vectors.\u003c/p\u003e\n"],["\u003cp\u003eEuler angle usage is discouraged due to potential Gimbal lock issues; quaternions or rotation matrices are preferred.\u003c/p\u003e\n"],["\u003cp\u003eThe forward vector in OpenGL points towards -Z, requiring inversion for right-handed systems.\u003c/p\u003e\n"]]],["The `HeadTransform` class provides methods to access head orientation and position data. Key actions include retrieving the head's rotation via `getEulerAngles` or `getQuaternion`, obtaining directional vectors such as `getForwardVector`, `getRightVector`, and `getUpVector`. Additionally, it supplies `getHeadView` to get a matrix for camera-to-head transformation and `getTranslation` to determine the head's relative position. Each method writes results into a provided float array at a specified offset.\n"],null,["# HeadTransform\n\npublic class **HeadTransform** \nDescribes the head transform independently of any eye parameters. \n\n### Public Constructors\n\n|---|-----------------------------------------------------------------------------------------------|\n| | [HeadTransform](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#HeadTransform())() |\n\n### Public Methods\n\n|------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [getEulerAngles](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getEulerAngles(float[],%20int))(float\\[\\] eulerAngles, int offset) Provides the Euler angles representation of the head rotation. |\n| void | [getForwardVector](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getForwardVector(float[],%20int))(float\\[\\] forward, int offset) Provides the direction the head is looking towards as a 3x1 unit vector. |\n| void | [getHeadView](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getHeadView(float[],%20int))(float\\[\\] headView, int offset) A matrix representing the transform from the camera to the head. |\n| void | [getQuaternion](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getQuaternion(float[],%20int))(float\\[\\] quaternion, int offset) Provides the quaternion representing the head rotation. |\n| void | [getRightVector](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getRightVector(float[],%20int))(float\\[\\] right, int offset) Provides the rightwards direction of the head as a 3x1 unit vector. |\n| void | [getTranslation](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getTranslation(float[],%20int))(float\\[\\] translation, int offset) Provides the relative translation of the head as a 3x1 vector. |\n| void | [getUpVector](/vr/reference/android/com/google/vr/sdk/base/HeadTransform#getUpVector(float[],%20int))(float\\[\\] up, int offset) Provides the upwards direction of the head as a 3x1 unit vector. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object) arg0) |\n| final [Class](https://developer.android.com/reference/java/lang/Class)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**HeadTransform**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public void\n**getEulerAngles**\n(float\\[\\] eulerAngles, int offset)\n\nProvides the Euler angles representation of the head rotation.\n\nUse of Euler angles is discouraged as they might be subject to Gimbal lock situations.\nUse quaternions or rotation matrices instead whenever possible.\n\nThe provided values represent the viewport rotation as pitch, yaw and roll angles\nwhere the matrix R = Rz(roll) \\* Rx(pitch) \\* Ry(yaw) represents the full rotation.\nThis rotation matrix order ensures both yaw and roll are in the full \\[-pi, pi\\] interval.\n\nThe angles are provided in radians, in this order and within the following intervals:\n\n- Pitch (X axis): \\[-pi/2, pi/2\\]\n- Yaw (Y axis): \\[-pi, pi\\]\n- Roll (Z axis): \\[-pi, pi\\]\n\nThe X-Y-Z axes are the basis of a right-handed OpenGL-style coordinate system.\nDuring Gimbal lock this method enforces yaw to 0 and provides a valid roll angle. \n\n##### Parameters\n\n| eulerAngles | Array where the 3 angles will be written to. |\n| offset | Offset in the array where data should be written. |\n|-------------|---------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getForwardVector**\n(float\\[\\] forward, int offset)\n\nProvides the direction the head is looking towards as a 3x1 unit vector.\n\nNote that in OpenGL the forward vector points into the -Z direction.\nMake sure to invert it if ever used to compute the basis of a right-handed system. \n\n##### Parameters\n\n| forward | Array where the forward vector will be written to. |\n| offset | Offset in the array where data should be written. |\n|---------|----------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getHeadView**\n(float\\[\\] headView, int offset)\n\nA matrix representing the transform from the camera to the head.\n\nHead origin is defined as the center point between the two eyes. \n\n##### Parameters\n\n| headView | Array where the 4x4 column-major transformation matrix will be written to. |\n| offset | Offset in the array where data should be written. |\n|----------|----------------------------------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getQuaternion**\n(float\\[\\] quaternion, int offset)\n\nProvides the quaternion representing the head rotation. \n\n##### Parameters\n\n| quaternion | Array where the quaternion (x, y, z, w) will be written to. |\n| offset | Offset in the array where data should be written. |\n|------------|-------------------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getRightVector**\n(float\\[\\] right, int offset)\n\nProvides the rightwards direction of the head as a 3x1 unit vector. \n\n##### Parameters\n\n| right | Array where the right vector will be written to. |\n| offset | Offset in the array where data should be written. |\n|--------|---------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getTranslation**\n(float\\[\\] translation, int offset)\n\nProvides the relative translation of the head as a 3x1 vector. \n\n##### Parameters\n\n| translation | Array where the translation vector will be written to. |\n| offset | Offset in the array where data should be written. |\n|-------------|--------------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|\n\n#### public void\n**getUpVector**\n(float\\[\\] up, int offset)\n\nProvides the upwards direction of the head as a 3x1 unit vector. \n\n##### Parameters\n\n| up | Array where the up vector will be written to. |\n| offset | Offset in the array where data should be written. |\n|--------|---------------------------------------------------|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If there is not enough space to write the result. |\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------|"]]