This forum has been archived. All content is frozen. Please use KDE Discuss instead.

quaternion constructor coefficient order

Tags: None
(comma "," separated)
lmka
Registered Member
Posts
4
Karma
0
What's the explanation for why the order of the coefficients in the quaternion constructor (i.e. Quaternion q(w,x,y,z)) is different from the storage order? Is it likely to stay this way in the future for compatibility / historical reasons?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
For the storage order: this is to make sure that q.w() == q.vec().w(), q.x() == q.vec().x(), etc...

For the ctor, this is because the most common order to enumerate the quaternion of a coefficient is (w,x,y,z).
lmka
Registered Member
Posts
4
Karma
0
I've gotten more used to seeing things enumerated in the storage order (4th element as the scalar part), which is what got me curious why the constructor was made differently. Oh well, I guess it's just a matter of preference and what books you read. Thanks
eudoxos
Registered Member
Posts
36
Karma
0
Hi,

I just found this post, dealing with eigen's Quaternion for the first time. If my voice counts, I would think rather strongly that the order should be the same in ctor as well as for storage, since one might use operator[] for component access. Either way it is, it is better than having 2 different ways IMHO. (In literature, from what I've seen the w+xi+yj+zk ordering is the most common, from what I've seen.)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]