Overview
Quaternion represents a unit quaternion used to encode 3D rotations. Unlike Euler angles, quaternions avoid gimbal lock and interpolate smoothly. The Transform.rotation property on a scene node stores a Quaternion.
The components are stored as (w, x, y, z) where w is the scalar part and (x, y, z) form the vector part.
Package: aspose.threed.utilities
Constructor
| Signature | Description |
|---|
Quaternion() | Identity quaternion (w=1, x=0, y=0, z=0) |
Quaternion(w, x, y, z) | Explicit component constructor |
Properties
| Name | Type | Description |
|---|
w | float | Scalar (real) part |
x | float | Vector x-component |
y | float | Vector y-component |
z | float | Vector z-component |
length | float | Magnitude of the quaternion |
Static Factory Methods
| Method | Return Type | Description |
|---|
Quaternion.from_euler_angle(pitch, yaw, roll) | Quaternion | Constructs from Euler angles in radians (pitch=X, yaw=Y, roll=Z). Also accepts a Vector3 as the first argument |
Quaternion.from_angle_axis(angle, axis) | Quaternion | Constructs from an angle (radians) and a Vector3 axis |
Quaternion.from_rotation(orig, dest) | Quaternion | Shortest-arc rotation from direction orig to direction dest |
Quaternion.interpolate(t, from_q, to_q) | Quaternion | SLERP interpolation; t in [0, 1] |
Quaternion.slerp(t, v1, v2) | Quaternion | Alias for interpolate |
Instance Methods
| Method | Return Type | Description |
|---|
normalize() | Quaternion | Returns a unit-length copy |
conjugate() | Quaternion | Returns the conjugate (w, -x, -y, -z) |
inverse() | Quaternion | Returns the multiplicative inverse; raises ValueError if length is zero |
dot(q) | float | Dot product with another quaternion |
concat(rhs) | Quaternion | Hamilton product (composition of two rotations) |
euler_angles() | Vector3 | Extracts Euler angles (radians) as Vector3(roll, pitch, yaw) |
to_matrix(translation=None) | Matrix4 | Converts to a 4×4 rotation matrix; optionally embeds a translation Vector3 |
to_angle_axis(angle, axis) | None | Decomposes into angle (radians) and axis; results written to single-element lists angle[0] and axis[0] |
Example
See Also