pythagoras.d

## Interface IQuaternion

• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `get(double[] values)`
Populates the supplied array with the contents of this quaternion.
`double` `getRotationZ()`
Returns the amount of rotation about the z axis (for the purpose of flattening the rotation).
`boolean` `hasNaN()`
Checks whether any of the components of this quaternion are not-numbers.
`Quaternion` ```integrate(IVector3 velocity, double t)```
Integrates the provided angular velocity over the specified timestep.
`Quaternion` ```integrate(IVector3 velocity, double t, Quaternion result)```
Integrates the provided angular velocity over the specified timestep, storing the result in the object provided.
`Quaternion` `invert()`
Inverts this quaternion.
`Quaternion` `invert(Quaternion result)`
Inverts this quaternion, storing the result in the object provided.
`Quaternion` `mult(IQuaternion other)`
Multiplies this quaternion by another.
`Quaternion` ```mult(IQuaternion other, Quaternion result)```
Multiplies this quaternion by another and stores the result in the provided object.
`Quaternion` `normalize()`
Normalizes this quaternion.
`Quaternion` `normalize(Quaternion result)`
Normalizes this quaternion, storing the result in the object provided.
`Quaternion` ```slerp(IQuaternion other, double t)```
Interpolates between this and the specified other quaternion.
`Quaternion` ```slerp(IQuaternion other, double t, Quaternion result)```
Interpolates between this and the specified other quaternion, placing the result in the object provided.
`Vector3` `toAngles()`
Computes and returns the angles to pass to `Quaternion.fromAngles(pythagoras.d.Vector3)` to reproduce this rotation.
`Vector3` `toAngles(Vector3 result)`
Computes the angles to pass to `Quaternion.fromAngles(pythagoras.d.Vector3)` to reproduce this rotation, placing them in the provided vector.
`Vector3` `transform(IVector3 vector)`
Transforms a vector by this quaternion.
`Vector3` ```transform(IVector3 vector, Vector3 result)```
Transforms a vector by this quaternion and places the result in the provided object.
`Vector3` ```transformAndAdd(IVector3 vector, IVector3 add, Vector3 result)```
Transforms a vector by this quaternion and adds another vector to it, placing the result in the object provided.
`Vector3` ```transformScaleAndAdd(IVector3 vector, double scale, IVector3 add, Vector3 result)```
Transforms a vector by this quaternion, applies a uniform scale, and adds another vector to it, placing the result in the object provided.
`Vector3` `transformUnitX(Vector3 result)`
Transforms the unit x vector by this quaternion, placing the result in the provided object.
`Vector3` `transformUnitY(Vector3 result)`
Transforms the unit y vector by this quaternion, placing the result in the provided object.
`Vector3` `transformUnitZ(Vector3 result)`
Transforms the unit z vector by this quaternion, placing the result in the provided object.
`double` `transformZ(IVector3 vector)`
Transforms a vector by this quaternion and returns the z coordinate of the result.
`double` `w()`
Returns the w-component of this quaternion.
`double` `x()`
Returns the x-component of this quaternion.
`double` `y()`
Returns the y-component of this quaternion.
`double` `z()`
Returns the z-component of this quaternion.
• ### Method Detail

• #### x

`double x()`
Returns the x-component of this quaternion.
• #### y

`double y()`
Returns the y-component of this quaternion.
• #### z

`double z()`
Returns the z-component of this quaternion.
• #### w

`double w()`
Returns the w-component of this quaternion.
• #### get

`void get(double[] values)`
Populates the supplied array with the contents of this quaternion.
• #### hasNaN

`boolean hasNaN()`
Checks whether any of the components of this quaternion are not-numbers.
• #### normalize

`Quaternion normalize()`
Normalizes this quaternion.
Returns:
a new quaternion containing the result.
• #### normalize

`Quaternion normalize(Quaternion result)`
Normalizes this quaternion, storing the result in the object provided.
Returns:
a reference to the result, for chaining.
• #### invert

`Quaternion invert()`
Inverts this quaternion.
Returns:
a new quaternion containing the result.
• #### invert

`Quaternion invert(Quaternion result)`
Inverts this quaternion, storing the result in the object provided.
Returns:
a reference to the result, for chaining.
• #### mult

`Quaternion mult(IQuaternion other)`
Multiplies this quaternion by another.
Returns:
a new quaternion containing the result.
• #### mult

```Quaternion mult(IQuaternion other,
Quaternion result)```
Multiplies this quaternion by another and stores the result in the provided object.
Returns:
a reference to the result, for chaining.
• #### slerp

```Quaternion slerp(IQuaternion other,
double t)```
Interpolates between this and the specified other quaternion.
Returns:
a new quaternion containing the result.
• #### slerp

```Quaternion slerp(IQuaternion other,
double t,
Quaternion result)```
Interpolates between this and the specified other quaternion, placing the result in the object provided. Based on the code in Nick Bobick's article, Rotating Objects Using Quaternions.
Returns:
a reference to the result quaternion, for chaining.
• #### transform

`Vector3 transform(IVector3 vector)`
Transforms a vector by this quaternion.
Returns:
a new vector containing the result.
• #### transform

```Vector3 transform(IVector3 vector,
Vector3 result)```
Transforms a vector by this quaternion and places the result in the provided object.
Returns:
a reference to the result, for chaining.
• #### transformUnitX

`Vector3 transformUnitX(Vector3 result)`
Transforms the unit x vector by this quaternion, placing the result in the provided object.
Returns:
a reference to the result, for chaining.
• #### transformUnitY

`Vector3 transformUnitY(Vector3 result)`
Transforms the unit y vector by this quaternion, placing the result in the provided object.
Returns:
a reference to the result, for chaining.
• #### transformUnitZ

`Vector3 transformUnitZ(Vector3 result)`
Transforms the unit z vector by this quaternion, placing the result in the provided object.
Returns:
a reference to the result, for chaining.

```Vector3 transformAndAdd(IVector3 vector,
Vector3 result)```
Transforms a vector by this quaternion and adds another vector to it, placing the result in the object provided.
Returns:
a reference to the result, for chaining.

```Vector3 transformScaleAndAdd(IVector3 vector,
double scale,
Vector3 result)```
Transforms a vector by this quaternion, applies a uniform scale, and adds another vector to it, placing the result in the object provided.
Returns:
a reference to the result, for chaining.
• #### transformZ

`double transformZ(IVector3 vector)`
Transforms a vector by this quaternion and returns the z coordinate of the result.
• #### getRotationZ

`double getRotationZ()`
Returns the amount of rotation about the z axis (for the purpose of flattening the rotation).
• #### integrate

```Quaternion integrate(IVector3 velocity,
double t)```
Integrates the provided angular velocity over the specified timestep.
Returns:
a new quaternion containing the result.
• #### integrate

```Quaternion integrate(IVector3 velocity,
double t,
Quaternion result)```
Integrates the provided angular velocity over the specified timestep, storing the result in the object provided.
Returns:
a reference to the result object, for chaining.