MCPcopy
hub / github.com/mne-tools/mne-python / rotation_angles

Function rotation_angles

mne/transforms.py:387–406  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

385
386
387def 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
409def scaling(x=1, y=1, z=1):

Callers 2

test_rotationFunction · 0.90
_load_transMethod · 0.85

Calls 1

sqrtMethod · 0.80

Tested by 1

test_rotationFunction · 0.72