MCPcopy Create free account
hub / github.com/MotrixLab/insactor / quat_angle_axis

Function quat_angle_axis

diffmimic/utils/quaternion.py:81–91  ·  view source on GitHub ↗

The (angle, axis) representation of the rotation. The axis is normalized to unit length. The angle is guaranteed to be between [0, pi].

(x)

Source from the content-addressed store, hash-verified

79 return quat_normalize(quat_mul(x, y))
80
81def 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
94def quat_identity(shape):

Callers 1

quat_diff_thetaFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected