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
, andw
.factory - Quaternion.axisAngle(Vector3 axis, double angle)
-
Constructs a quaternion from a rotation of
angle
aroundaxis
.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 velocityomega
.factory - Quaternion.euler(double yaw, double pitch, double roll)
-
Constructs a quaternion from
yaw
,pitch
androll
.factory - Quaternion.fromBuffer(ByteBuffer buffer, int offset)
-
Constructs a quaternion with a storage that views given
buffer
starting atoffset
.offset
has to be multiple of Float32List.bytesPerElement. - Quaternion.fromFloat32List(Float32List _qStorage)
- Constructs a quaternion with given Float32List 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
tob
.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.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- length → double
-
Length.
no setter
- length2 → double
-
Length squared.
no setter
- radians → double
-
radians of rotation around the axis of the rotation.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storage → Float32List
-
Access the internal storage of the quaternions components.
no setter
- w ↔ double
-
Access the w component of the quaternion.
getter/setter pair
- x ↔ double
-
Access the x component of the quaternion.
getter/setter pair
- y ↔ double
-
Access the y component of the quaternion.
getter/setter pair
- z ↔ double
-
Access the z component of the quaternion.
getter/setter pair
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.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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
aroundaxis
. -
setDQ(
Quaternion q, Vector3 omega) → void -
Set the quaternion to the time derivative of
q
with angular velocityomega
. -
setEuler(
double yaw, double pitch, double roll) → void -
Set quaternion with rotation of
yaw
,pitch
androll
. -
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
, andw
. -
sub(
Quaternion arg) → void -
Subtracts
arg
from this. -
toString(
) → String -
Printable string.
override
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 ==(
Object other) → bool -
The equality operator.
inherited
-
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.