Quaternion class

A quaternion number of the form w + x*i + y*j + z*k.

Implemented types
Annotations
  • @immutable

Constructors

Quaternion(num w, [num x = 0, num y = 0, num z = 0])
Constructs a quaternion from its components.
const
Quaternion.fromAxis(List<num> axis, num angle)
Constructs a quaternion from an axis and a rotation angle.
factory
Quaternion.fromEuler(num phi, num theta, num psi)
Constructs a quaternion from an euler rotation.
factory
Quaternion.fromList(List<num> vector)
Constructs a quaternion from a vector.
factory
Quaternion.fromVectors(List<num> source, List<num> target)
Constructs a quaternion from the rotation between two vectors source and target.
factory
Quaternion.of(num scalar, List<num> vector)
Constructs a quaternion from a scalar and a vector.
factory
Quaternion.parse(String source)
Parses source as a Quaternion. Throws a FormatException for invalid input.
factory

Properties

hashCode → int
The hash code for this object.
no setteroverride
isFinite → bool
Tests if this quaternion is finite.
no setter
isInfinite → bool
Tests if this quaternion is infinite.
no setter
isNaN → bool
Tests if this quaternion is not defined.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
w → num
The 1st quaternion unit (scalar part).
final
x → num
The 2nd quaternion unit (1st vector/imaginary part).
final
y → num
The 3rd quaternion unit (2nd vector/imaginary part).
final
z → num
The 4th quaternion unit (3rd vector/imaginary part).
final

Methods

abs() → double
Returns the absolute value of the quaternion.
ceil() → Quaternion
Ceils the values of this quaternion to integers.
closeTo(Quaternion other, num epsilon) → bool
Tests if this object is close to another object.
override
conjugate() → Quaternion
Returns the conjugate form of the quaternion.
exp() → Quaternion
Computes the exponential function of this quaternion number.
floor() → Quaternion
Floors the values of this quaternion to integers.
log() → Quaternion
Computes the natural logarithm of this quaternion number.
norm() → num
Returns the squared absolute value.
normalize() → Quaternion
Returns the normalized form of the quaternion.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pow(Object exponent) → Quaternion
Computes the power of this quaternion number raised to exponent.
reciprocal() → Quaternion
Computes the multiplicative inverse of this quaternion.
round() → Quaternion
Rounds the values of this quaternion to integers.
toString() → String
A string representation of this object.
override
truncate() → Quaternion
Truncates the values of this quaternion to integers.

Operators

operator *(Object other) → Quaternion
Returns the product of this number and another one.
operator +(Object other) → Quaternion
Returns the sum of this number and another one.
operator -(Object other) → Quaternion
Returns the difference of this number and another one.
operator /(Object other) → Quaternion
Computes the division of this number and another one.
operator ==(Object other) → bool
The equality operator.
override
operator unary-() → Quaternion
Returns the negated form of the quaternion.

Static Methods

tryParse(String source) → Quaternion?
Parses source as a Quaternion. Returns null in case of a problem.

Constants

i → const Quaternion
The quaternion i unit.
infinity → const Quaternion
The quaternion number with all parts being double.infinity.
j → const Quaternion
The quaternion j unit.
k → const Quaternion
The quaternion k unit.
nan → const Quaternion
The quaternion number with all parts being double.nan.
one → const Quaternion
The neutral multiplicative element, that is 1.
zero → const Quaternion
The neutral additive element, that is 0.