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, )
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( 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, )
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
axis of rotation.
length
Length.
length2
Length squared.
radians of rotation around the axis of the rotation.
storage
Access the internal storage of the quaternions components.
w
Access the w component of the quaternion.
x
Access the x component of the quaternion.
y
Access the y component of the quaternion.
z
Access the z component of the quaternion.
hashCode int
The hash code for this object. [...]
runtimeType Type
A representation of the runtime type of the object.

Methods

absoluteError(Quaternion correct)
Absolute error between this and correct.
add(Quaternion arg) → void
Add arg to this.
asRotationMatrix()
Returns a rotation matrix containing the same rotation as this.
clone()
Returns a new copy of this.
conjugate() → void
Conjugate this.
conjugated()
Conjugated copy of this.
copyRotationInto(Matrix3 rotationMatrix)
Set rotationMatrix to a rotation matrix containing the same rotation as this.
inverse() → void
Invert this.
inverted()
Inverted copy of this.
normalize()
Normalize this.
normalized()
Normalized copy of this.
relativeError(Quaternion correct)
Relative error between this and correct.
rotate()
Rotates v by this.
rotated()
Returns a copy of v rotated by quaternion.
scale(double scale) → void
Scales this by scale.
scaled(double scale)
Scaled copy of this.
setAxisAngle(Vector3 axis, double radians) → void
Set the quaternion with rotation of radians around axis.
setDQ( 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, ) → 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, ) → void
Set the quaternion to the raw values x, y, z, and w.
sub(Quaternion arg) → void
Subtracts arg from this.
toString()
Printable string.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator *(Quaternion other)
this rotated by other.
operator +(Quaternion other)
Returns copy of this + other.
operator -(Quaternion other)
Returns copy of this - other.
operator [](int i)
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-()
Returns negated copy of this.
operator ==(dynamic other) bool
The equality operator. [...]
inherited