Product of two quaternions i*i = j*j = k*k = i*j*k = -1 Quaternion multiplication can be expressed concisely using scalar and vector parts, see
(self, other)
| 4328 | return self.__class__(-self.scalar, -self.vector) |
| 4329 | |
| 4330 | def __mul__(self, other): |
| 4331 | """ |
| 4332 | Product of two quaternions |
| 4333 | i*i = j*j = k*k = i*j*k = -1 |
| 4334 | Quaternion multiplication can be expressed concisely |
| 4335 | using scalar and vector parts, |
| 4336 | see <https://en.wikipedia.org/wiki/Quaternion#Scalar_and_vector_parts> |
| 4337 | """ |
| 4338 | return self.__class__( |
| 4339 | self.scalar*other.scalar - np.dot(self.vector, other.vector), |
| 4340 | self.scalar*other.vector + self.vector*other.scalar |
| 4341 | + np.cross(self.vector, other.vector)) |
| 4342 | |
| 4343 | def conjugate(self): |
| 4344 | """The conjugate quaternion -(1/2)*(q+i*q*i+j*q*j+k*q*k)""" |