symforce.geo.quaternion module#
- class Quaternion(xyz, w)[source]#
Bases:
Group
Unit quaternions, also known as versors, provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles they are simpler to compose and avoid the problem of gimbal lock. Compared to rotation matrices they are more compact, more numerically stable, and more efficient.
Storage is (x, y, z, w).
References
https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
- Parameters:
xyz (Vector3) –
w (T.Scalar) –
- to_storage()[source]#
Flat list representation of the underlying storage, length of
storage_dim()
. This is used purely for plumbing, it is NOT like a tangent space.
- classmethod from_storage(vec)[source]#
Construct from a flat list representation. Opposite of
to_storage()
.- Parameters:
- Return type:
- classmethod symbolic(name, **kwargs)[source]#
Construct a symbolic element with the given name prefix. Kwargs are forwarded to
sf.Symbol
(for example, sympy assumptions).- Parameters:
- Return type:
- compose(other)[source]#
Apply the group operation with other.
- Parameters:
other (Quaternion) –
- Return type:
- __mul__(right)[source]#
Quaternion multiplication.
- Parameters:
right (Quaternion) –
- Returns:
Quaternion
- Return type:
- __add__(right)[source]#
Quaternion addition.
- Parameters:
right (Quaternion) –
- Returns:
Quaternion
- Return type:
- __div__(scalar)[source]#
Scalar division.
- Parameters:
scalar (Scalar) –
- Returns:
Quaternion
- Return type:
- __truediv__(scalar)#
Scalar division.
- Parameters:
scalar (Scalar) –
- Returns:
Quaternion
- Return type:
- squared_norm()[source]#
Squared norm when considering the quaternion as 4-tuple.
- Returns:
Scalar
- Return type: