(one, two)
| 1435 | |
| 1436 | |
| 1437 | def _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 | |
| 1457 | def _skew_symmetric_cross(a): |
no test coverage detected