Overview
Quaternion represents a unit quaternion used for rotation. It avoids gimbal lock and provides smooth interpolation between orientations. The Transform class stores rotation as a Quaternion accessible via getRotation() / setRotation().
Package: com.aspose.threed
Constructor
| Signature | Description |
|---|
Quaternion() | Identity quaternion (1, 0, 0, 0) |
Quaternion(double w, double x, double y, double z) | Constructs from four components |
Public Fields
Quaternion uses public fields for component access (not getter/setter methods):
| Field | Type | Access | Description |
|---|
w | double | q.w | Scalar (real) part |
x | double | q.x | X component of the vector part |
y | double | q.y | Y component of the vector part |
z | double | q.z | Z component of the vector part |
Computed Properties
| Name | Type | Getter | Description |
|---|
length | double | getLength() | Magnitude of the quaternion (should be 1.0 for a unit quaternion) |
Static Fields
| Field | Type | Description |
|---|
IDENTITY | Quaternion | The identity quaternion (1, 0, 0, 0) – no rotation |
Static Methods
| Method | Return Type | Description |
|---|
Quaternion.fromEuler(double x, double y, double z) | Quaternion | Creates a quaternion from Euler angles in degrees |
Quaternion.fromAngleAxis(double angle, Vector3 axis) | Quaternion | Creates a quaternion from an angle (radians) and rotation axis |
Instance Methods
| Method | Return Type | Description |
|---|
normalize() | Quaternion | Returns a unit-length copy |
conjugate() | Quaternion | Returns the conjugate (negated vector part) |
inverse() | Quaternion | Returns the multiplicative inverse |
toEulerAngles() | Vector3 | Converts to Euler angles in degrees |
toMatrix() | Matrix4 | Converts to a 4x4 rotation matrix |
Example
See Also