← Back to team overview

yade-users team mailing list archive

Re: [Question #705414]: Accessing Quaternions' Components


Question #705414 on Yade changed:

Jan Stránský posted a new comment:

just a clarification and tips.
(you have solved the problems, but others may come here searching same or similar topics)

> When I try to access the components of this quaternion using q[0], q[1], q[2], q[3];
it returns .... The individual components are different than that is in the Quaternion.

q[index] returns actutal quaternion components (a,b,c,d in [1], sometimes also denoted w,x,y,z)
I am not sure with the order (component "a" is q[0] or q[3], but it is documented in Eigen).

> t = q.toAngleAxis()
> One can easily access the components now. t[0][0], t[0][1], t[0][2] are the i,j,k values of the quaternion, and t[1] is the angle.

for t = q.toAngleAxis() t[0] is angle, t[1] is axis
for t = q.toAxisAngle() t[0] is axis, t[1] is angle
(you have it somehow mixed)

A more pythonic and understandable code would be:
axis, angle = q.toAxisAngle()
or even
(i, j, k), angle = q.toAxisAngle()


[1] https://en.wikipedia.org/wiki/Quaternion

You received this question notification because your team yade-users is
an answer contact for Yade.