October 15, 2019 update:
• The Daydream View VR headset is no longer available for purchase. However, developers can continue to use the existing Google VR SDK to update and distribute their apps to the Google Play Store, and make them available to users in the Daydream app.

# Orientation

public class Orientation

Represents the 3-dimensional orientation of a `Controller` as a unit Quaternion.

### Fields

 public float w W component representing the real part of the quaternion. public float x X component representing the i basis element. public float y Y component representing the j basis element. public float z Z component representing the k basis element.

### Public Constructors

 Orientation(float x, float y, float z, float w) Construct an Orientation with the provided values which represent a normalized quaternion.

### Public Methods

 static Orientation fromAxisAngleDegrees(float x, float y, float z, float degrees) Construct an Orientation from a normalized axis-angle representation. void set(float[] xyzw) Set the Orientation to the given values which represent a normalized quaternion. void set(float x, float y, float z, float w) Set the Orientation to the given values which represent a normalized quaternion. String toAxisAngleString() Converts the orientation into an axis-angle representation. float[] toForwardVector(float[] xyz) Returns the result of multiplying <0, 0, -1> by this orientation. float[] toRotationMatrix(float[] output) Converts this Orientation to a 4x4 matrix. String toString() Converts the orientation into a printable string. float[] toYawPitchRollDegrees(float[] angles) float[] toYawPitchRollRadians(float[] angles) Convert this orientation to a trio of Euler angles.

## Fields

#### public float w

W component representing the real part of the quaternion.

#### public float x

X component representing the i basis element.

#### public float y

Y component representing the j basis element.

#### public float z

Z component representing the k basis element.

## Public Constructors

#### public Orientation(float x, float y, float z, float w)

Construct an Orientation with the provided values which represent a normalized quaternion.

## Public Methods

#### public static Orientation fromAxisAngleDegrees(float x, float y, float z, float degrees)

Construct an Orientation from a normalized axis-angle representation.

#### public void set(float[] xyzw)

Set the Orientation to the given values which represent a normalized quaternion.

#### public void set(float x, float y, float z, float w)

Set the Orientation to the given values which represent a normalized quaternion.

#### public String toAxisAngleString()

Converts the orientation into an axis-angle representation.

The normalized Euler axis is given first and the clockwise rotation is represented in degrees.

##### Returns
• Formatted representation of the orientation. E.g, "( 0.56, 5.58, 0.59) 51"

#### public float[] toForwardVector(float[] xyz)

Returns the result of multiplying <0, 0, -1> by this orientation. This represents the pitch and yaw of the controller.

##### Parameters
xyz 3-element array to hold the output vector.
• xyz

#### public float[] toRotationMatrix(float[] output)

Converts this Orientation to a 4x4 matrix.

The output is column-major which matches OpenGL and Android convention.

##### Parameters
output An array of size 16.
##### Returns
• output with elements as a column-major matrix.

#### public String toString()

Converts the orientation into a printable string. The order of elements is "x, y, z, w" and the x, y, and z elements are labeled with i, j, and k basis elements, respectively.

##### Returns
• Formatted representation of the orientation. E.g, " 0.24i 0.24j 0.26k 0.82"