MCPcopy Create free account
hub / github.com/ALRhub/X_IL / axisangle2quat_numpy

Function axisangle2quat_numpy

utils/transform_utils.py:53–71  ·  view source on GitHub ↗

Converts scaled axis-angle to quat for multiple vectors. Args: vecs (np.ndarray): (N, 3) array of axis-angle exponential coordinates Returns: np.ndarray: (N, 4) array of quaternions (x, y, z, w)

(vecs)

Source from the content-addressed store, hash-verified

51
52
53def axisangle2quat_numpy(vecs):
54 """
55 Converts scaled axis-angle to quat for multiple vectors.
56
57 Args:
58 vecs (np.ndarray): (N, 3) array of axis-angle exponential coordinates
59
60 Returns:
61 np.ndarray: (N, 4) array of quaternions (x, y, z, w)
62 """
63 angles = np.linalg.norm(vecs, axis=1)
64 axes = np.divide(vecs.T, angles, where=angles != 0).T # Avoid division by zero
65
66 quats = np.zeros((vecs.shape[0], 4))
67 quats[:, 3] = np.cos(angles / 2.0)
68 quats[:, :3] = axes * np.sin(angles / 2.0)[:, np.newaxis]
69 quats[angles == 0, 3] = 1.0 # Handle zero-rotation case
70
71 return quats
72
73
74def axisangle2quat_torch(vecs):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected