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

Function _quat_mult

mne/transforms.py:1437–1454  ·  view source on GitHub ↗
(one, two)

Source from the content-addressed store, hash-verified

1435
1436
1437def _quat_mult(one, two):
1438 assert one.shape[-1] == two.shape[-1] == 3
1439 w1 = _quat_real(one)
1440 w2 = _quat_real(two)
1441 out = np.empty(np.broadcast(one, two).shape)
1442 # Most mathematical expressions use this sort of notation
1443 x1, x2 = one[..., 0], two[..., 0]
1444 y1, y2 = one[..., 1], two[..., 1]
1445 z1, z2 = one[..., 2], two[..., 2]
1446 out[..., 0] = w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2
1447 out[..., 1] = w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2
1448 out[..., 2] = w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2
1449 # only need to compute w because we need signs from it
1450 w = w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2
1451 signs = np.sign(w)
1452 signs = np.where(signs, signs, 1)
1453 out *= signs[..., np.newaxis]
1454 return out
1455
1456
1457def _skew_symmetric_cross(a):

Callers 1

_angle_between_quatsFunction · 0.85

Calls 1

_quat_realFunction · 0.85

Tested by

no test coverage detected