Quaternion class

A class representing a quaternion.

The quaternion number system extends the complex numbers. Quaternions have practical uses in applied mathematics, particularly for calculations involving three-dimensional rotations, such as in three-dimensional computer graphics, computer vision, magnetic resonance imaging and crystallographic texture analysis. They can be used alongside other methods of rotation, such as Euler angles and rotation matrices, or as an alternative to them, depending on the application.

Annotations

Constructors

Quaternion(double x, double y, double z, double w)
Constructs a Quaternion with given x, y, z, w components
Quaternion.identity()
constructs an identity Quaternion (0, 0, 0, 1)
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
length double
The length (magnitude) of this quaternion.
no setter
length2 double
The squared length of this quaternion.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
w double
The w component of the quaternion.
no setter
x double
The x component of the quaternion.
no setter
y double
The y component of the quaternion.
no setter
z double
The z component of the quaternion.
no setter

Methods

apply(double f(double)) Quaternion
Applies a function f to each component of this quaternion and returns a new Quaternion.
conjugate() Quaternion
Returns the conjugate of this quaternion.
invert() Quaternion
Inverts the quaternion.
multiply(Quaternion o) Quaternion
Computes the Hamilton product of this quaternion with another Quaternion.
normalize() Quaternion
Normalizes this quaternion.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toAxisAngle() AxisAngle
Converts quaternion to axis-angle representation.
toRotationMatrix() Matrix3
Converts quaternion to rotation matrix.
toString() String
A string representation of this object.
override

Operators

operator *(double s) Quaternion
Multiplies this quaternion by a scalar.
operator +(Quaternion o) Quaternion
Adds this quaternion with another Quaternion.
operator -(Quaternion o) Quaternion
Subtracts another Quaternion from this quaternion.
operator /(double s) Quaternion
Divides this quaternion by a scalar.
operator ==(Object other) bool
Determines whether this quaternion is equal to another object. Returns true if the other object is an Quaternion with the same components.
override
operator unary-() Quaternion
Negates this quaternion.