quaternion_utils.py
cpas_toolbox.quaternion_utils ¶
Functions to handle transformations with quaternions.
Inspired by PyTorch3D, but using scalar-last convention and not enforcing scalar > 0. https://github.com/facebookresearch/pytorch3d
quaternion_multiply ¶
Multiply two quaternions representing rotations.
Normal broadcasting rules apply.
PARAMETER | DESCRIPTION |
---|---|
quaternions_1 |
normalized quaternions of shape (..., 4), scalar-last convention
TYPE:
|
quaternions_2 |
normalized quaternions of shape (..., 4), scalar-last convention
TYPE:
|
Returns: Composition of passed quaternions.
Source code in cpas_toolbox/quaternion_utils.py
quaternion_apply ¶
Rotate points by quaternions representing rotations.
Normal broadcasting rules apply.
PARAMETER | DESCRIPTION |
---|---|
quaternions |
normalized quaternions of shape (..., 4), scalar-last convention
TYPE:
|
points |
points of shape (..., 3)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
Points rotated by the rotations representing quaternions. |
Source code in cpas_toolbox/quaternion_utils.py
quaternion_invert ¶
Invert quaternions representing orientations.
PARAMETER | DESCRIPTION |
---|---|
quaternions |
The quaternions to invert, shape (..., 4), scalar-last convention.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
Inverted quaternions, same shape as quaternions. |
Source code in cpas_toolbox/quaternion_utils.py
geodesic_distance ¶
Compute geodesic distances between quaternions.
PARAMETER | DESCRIPTION |
---|---|
q1 |
First set of quaterions, shape (N,4).
TYPE:
|
q2 |
Second set of quaternions, shape (N,4).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tensor
|
Mean distance between the quaternions, scalar. |