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
generate_uniform_quaternion()
Generate a normalized uniform quaternion.
Following the method from K. Shoemake, Uniform Random Rotations, 1992.
See: http://planning.cs.uiuc.edu/node198.html
Returns:
Type | Description |
---|---|
Tensor
|
Uniformly distributed unit quaternion on the estimator's device. |
Source code in sdfest/initialization/quaternion_utils.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
geodesic_distance(q1, q2)
Compute geodesic distances between quaternions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
Tensor
|
First set of quaterions, shape (N,4). |
required |
q2 |
Tensor
|
Second set of quaternions, shape (N,4). |
required |
Returns: Mean distance between the quaternions, scalar.
Source code in sdfest/initialization/quaternion_utils.py
69 70 71 72 73 74 75 76 77 78 79 80 |
|
quaternion_apply(quaternions, points)
Rotate points by quaternions representing rotations.
Normal broadcasting rules apply.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quaternions |
Tensor
|
normalized quaternions of shape (..., 4), scalar-last convention |
required |
points |
Tensor
|
points of shape (..., 3) |
required |
Returns: Points rotated by the rotations representing quaternions.
Source code in sdfest/initialization/quaternion_utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
quaternion_invert(quaternions)
Invert quaternions representing orientations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quaternions |
Tensor
|
The quaternions to invert, shape (..., 4), scalar-last convention. |
required |
Returns: Inverted quaternions, same shape as quaternions.
Source code in sdfest/initialization/quaternion_utils.py
57 58 59 60 61 62 63 64 65 66 |
|
quaternion_multiply(quaternions_1, quaternions_2)
Multiply two quaternions representing rotations.
Normal broadcasting rules apply.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quaternions_1 |
Tensor
|
normalized quaternions of shape (..., 4), scalar-last convention |
required |
quaternions_2 |
Tensor
|
normalized quaternions of shape (..., 4), scalar-last convention |
required |
Returns: Composition of passed quaternions.
Source code in sdfest/initialization/quaternion_utils.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
simple_quaternion_loss(q1, q2)
Compute distance measure between quaternions not involving trig functions.
From
https://math.stackexchange.com/a/90098
Parameters:
Name | Type | Description | Default |
---|---|---|---|
q1 |
Tensor
|
First set of quaterions, shape (N,4). |
required |
q2 |
Tensor
|
Second set of quaternions, shape (N,4). |
required |
Returns: Mean distance between the quaternions, scalar.
Source code in sdfest/initialization/quaternion_utils.py
83 84 85 86 87 88 89 90 91 92 93 94 95 |
|