Find rotation angles from a transformation matrix. Parameters ---------- m : array, shape >= (3, 3) Rotation matrix. Only the top left 3 x 3 partition is accessed. Returns ------- x, y, z : float Rotation around x, y and z axes.
(m)
| 385 | |
| 386 | |
| 387 | def rotation_angles(m): |
| 388 | """Find rotation angles from a transformation matrix. |
| 389 | |
| 390 | Parameters |
| 391 | ---------- |
| 392 | m : array, shape >= (3, 3) |
| 393 | Rotation matrix. Only the top left 3 x 3 partition is accessed. |
| 394 | |
| 395 | Returns |
| 396 | ------- |
| 397 | x, y, z : float |
| 398 | Rotation around x, y and z axes. |
| 399 | """ |
| 400 | x = np.arctan2(m[2, 1], m[2, 2]) |
| 401 | c2 = np.sqrt(m[0, 0] ** 2 + m[1, 0] ** 2) |
| 402 | y = np.arctan2(-m[2, 0], c2) |
| 403 | s1 = np.sin(x) |
| 404 | c1 = np.cos(x) |
| 405 | z = np.arctan2(s1 * m[0, 2] - c1 * m[0, 1], c1 * m[1, 1] - s1 * m[1, 2]) |
| 406 | return x, y, z |
| 407 | |
| 408 | |
| 409 | def scaling(x=1, y=1, z=1): |