adamlwgriffiths / Pyrr

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

Multiplication of a quaternion by an integer vector is incorrect #35

Closed japagetw closed 5 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
>>> q = Quaternion([0.36, 0.288, 0.384, 0.8])
>>> v = Vector3([1, 1, 1])
>>> q*v
Vector3([ 0.,  0.,  0.])
>>> w = Vector3([1., 1., 1.])
>>> q*w
Vector3([ 1.17664 ,  0.836032,  0.957376])

The results of q*v and q*w should be the same.

adamlwgriffiths commented 9 years ago

This is due to the vector inheriting the dtype from the original vector ndarray. If you increase the values, to say [100,100,100], then they will be non-zero.

If you feel there is a legitimate enough reason to alter this logic, I'm all ears. However, I'm inclined to leave it this way as I would rather preserve dtypes than have them change without the user's knowledge, which is consistent with the rest of the library.

adamlwgriffiths commented 9 years ago

Thinking about it more, numpy does automatic conversion to other dtypes, I guess pyrr should just do what numpy does.

adamlwgriffiths commented 5 years ago

duplicated by #80