Vectors and matrices had this from the beginning on as in their case, the semantics is fairly unambiguous whereas in the case of the quaternion it's not as clear to me anymore. Should list(q) be [w, x, y, z] or [x, y, z, w]? And why should one be preferable over the other?
That's why I decided people should rather be explicit and spell out the list as above (you have surely heard of Python's Zen: "explicit is better than implicit" (http://www.python.org/dev/peps/pep-0020/) :-)
So instead of list(q) you could rather write [q.w, q.x, q.y, q.z], then at least anybody reading your program exctly knows what they are dealing with.
(if you have a use-case where the ability to index a quaternion or iterate over it would substantially simpify your program, I might be convinced and reconsider my decision)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
len() and q[0] should work also
Vectors and matrices had this from the beginning on as in their case, the semantics is fairly unambiguous whereas in the case of the quaternion it's not as clear to me anymore. Should list(q) be [w, x, y, z] or [x, y, z, w]? And why should one be preferable over the other?
That's why I decided people should rather be explicit and spell out the list as above (you have surely heard of Python's Zen: "explicit is better than implicit" (http://www.python.org/dev/peps/pep-0020/) :-)
So instead of list(q) you could rather write [q.w, q.x, q.y, q.z], then at least anybody reading your program exctly knows what they are dealing with.
(if you have a use-case where the ability to index a quaternion or iterate over it would substantially simpify your program, I might be convinced and reconsider my decision)
Well, the use case is convertion to and from scipy/numpy.
Since the constructor already breaks that "explicit better than implicit" guideline, why not extending it to iterable interface :
# set all four components (w,x,y,z)
q = quat(1,0,0,0)
q = quat([1,0,0,0])
q = quat("1,0,0,0")
thanks :)