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)
| 51 | |
| 52 | |
| 53 | def 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 | |
| 74 | def axisangle2quat_torch(vecs): |
nothing calls this directly
no outgoing calls
no test coverage detected