Quaternion class

Defines a Quaternion (a four-dimensional vector) for efficient rotation calculations.

Quaternion are better for interpolating between rotations and avoid the gimbal lock problem compared to euler rotations.

Constructors

Quaternion(double x, double y, double z, double w)
Constructs a quaternion using the raw values x, y, z, and w.
factory
Quaternion.axisAngle(Vector3 axis, double angle)
Constructs a quaternion from a rotation of angle around axis.
factory
Quaternion.copy(Quaternion original)
Constructs a quaternion as a copy of original.
factory
Quaternion.dq(Quaternion q, Vector3 omega)
Constructs a quaternion from time derivative of q with angular velocity omega.
factory
Quaternion.euler(double yaw, double pitch, double roll)
Constructs a quaternion from yaw, pitch and roll.
factory
Quaternion.fromBuffer(ByteBuffer buffer, int offset)
Constructs a quaternion with a storage that views given buffer starting at offset. offset has to be multiple of Float64List.bytesPerElement.
Quaternion.fromFloat64List(Float64List _qStorage)
Constructs a quaternion with given Float64List as storage.
Quaternion.fromRotation(Matrix3 rotationMatrix)
Constructs a quaternion from a rotation matrix rotationMatrix.
factory
Quaternion.fromTwoVectors(Vector3 a, Vector3 b)
Constructs a quaternion to be the rotation that rotates vector a to b.
factory
Quaternion.identity()
Constructs a quaternion set to the identity quaternion.
factory
Quaternion.random(Random rn)
Constructs a quaternion with a random rotation. The random number generator rn is used to generate the random numbers for the rotation.
factory

Properties

axis Vector3
axis of rotation.
read-only
length double
Length.
read-only
length2 double
Length squared.
read-only
radians double
radians of rotation around the axis of the rotation.
read-only
storage Float64List
Access the internal storage of the quaternions components.
read-only
w double
Access the w component of the quaternion.
read / write
x double
Access the x component of the quaternion.
read / write
y double
Access the y component of the quaternion.
read / write
z double
Access the z component of the quaternion.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

absoluteError(Quaternion correct) double
Absolute error between this and correct.
add(Quaternion arg) → void
Add arg to this.
asRotationMatrix() Matrix3
Returns a rotation matrix containing the same rotation as this.
clone() Quaternion
Returns a new copy of this.
conjugate() → void
Conjugate this.
conjugated() Quaternion
Conjugated copy of this.
copyRotationInto(Matrix3 rotationMatrix) Matrix3
Set rotationMatrix to a rotation matrix containing the same rotation as this.
inverse() → void
Invert this.
inverted() Quaternion
Inverted copy of this.
normalize() double
Normalize this.
normalized() Quaternion
Normalized copy of this.
relativeError(Quaternion correct) double
Relative error between this and correct.
rotate(Vector3 v) Vector3
Rotates v by this.
rotated(Vector3 v) Vector3
Returns a copy of v rotated by quaternion.
scale(double scale) → void
Scales this by scale.
scaled(double scale) Quaternion
Scaled copy of this.
setAxisAngle(Vector3 axis, double radians) → void
Set the quaternion with rotation of radians around axis.
setDQ(Quaternion q, Vector3 omega) → void
Set the quaternion to the time derivative of q with angular velocity omega.
setEuler(double yaw, double pitch, double roll) → void
Set quaternion with rotation of yaw, pitch and roll.
setFrom(Quaternion source) → void
Copy source into this.
setFromRotation(Matrix3 rotationMatrix) → void
Set the quaternion with rotation from a rotation matrix rotationMatrix.
setFromTwoVectors(Vector3 a, Vector3 b) → void
setRandom(Random rn) → void
Set the quaternion to a random rotation. The random number generator rn is used to generate the random numbers for the rotation.
setValues(double x, double y, double z, double w) → void
Set the quaternion to the raw values x, y, z, and w.
sub(Quaternion arg) → void
Subtracts arg from this.
toString() String
Printable string.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator *(Quaternion other) Quaternion
this rotated by other.
operator +(Quaternion other) Quaternion
Returns copy of this + other.
operator -(Quaternion other) Quaternion
Returns copy of this - other.
operator [](int i) double
Access the component of the quaternion at the index i.
operator []=(int i, double arg) → void
Set the component of the quaternion at the index i.
operator unary-() Quaternion
Returns negated copy of this.
operator ==(dynamic other) bool
The equality operator. [...]
inherited