The (angle, axis) representation of the rotation. The axis is normalized to unit length. The angle is guaranteed to be between [0, pi].
(x)
| 79 | return quat_normalize(quat_mul(x, y)) |
| 80 | |
| 81 | def quat_angle_axis(x): |
| 82 | """ |
| 83 | The (angle, axis) representation of the rotation. The axis is normalized to unit length. |
| 84 | The angle is guaranteed to be between [0, pi]. |
| 85 | """ |
| 86 | s = 2 * (x[..., 3] ** 2) - 1 |
| 87 | angle = jp.arccos(jp.clip(s, a_min=jp.ones_like(s)*-1, a_max=jp.ones_like(s))) # just to be safe |
| 88 | axis = x[..., :3] |
| 89 | norm = jp.safe_norm(axis, axis=-1)[..., None] |
| 90 | axis /= jp.clip(norm, a_min=jp.ones_like(norm)*1e-9, a_max=jp.ones_like(norm)*1e9) |
| 91 | return angle, axis |
| 92 | |
| 93 | |
| 94 | def quat_identity(shape): |