adamlwgriffiths / Pyrr

3D mathematical functions using NumPy
Other
403 stars 57 forks source link

Quaternion multiplication is incorrect #34

Closed japagetw closed 9 years ago

japagetw commented 9 years ago
C:\>python
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.10.1'
>>> from pyrr import Quaternion, Matrix33, Matrix44, Vector3, Vector4
>>> i = Quaternion([1., 0., 0., 0.])
>>> j = Quaternion([0., 1., 0., 0.])
>>> k = Quaternion([0., 0., 1., 0.])
>>> i*j
Quaternion([ 0.,  0., -1.,  0.])
>>> j*k
Quaternion([-1.,  0.,  0.,  0.])
>>> i*j*k
Quaternion([ 0.,  0.,  0.,  1.])

This is contrary to the well-known relations i*j = k, j*k = i, and i*j*k = -1.

adamlwgriffiths commented 9 years ago

Hopefully I'll get time to look at this today.

adamlwgriffiths commented 9 years ago

Thanks for raising the issue, I've fixed it and added tests to ensure it won't crop up again. Sorry it took so long to get around to it, I've been rather busy.