c++ - Quaternion to EulerXYZ, how to differentiate the negative and positive quaternion -
i've been trying figure out difference between these, , why toeulerxyz not right rotation.
using mathgeolib:
axisx:
x 0.80878228 float y -0.58810818 float z 0.00000000 float
axisy:
x 0.58811820 float y 0.80877501 float z 0.00000000 float
axisz:
x 0.00000000 float y 0.00000000 float z 1.0000000 float
code:
quat aq = quat::rotateaxisangle(axisx, degtorad(30)) * quat::rotateaxisangle(axisy, degtorad(60)) * quat::rotateaxisangle(axisz, degtorad(40)); float3 euleranglesa = aq.toeulerxyz(); quat bq = quat::rotateaxisangle(axisx, degtorad(-150)) * quat::rotateaxisangle(axisy, degtorad(120)) * quat::rotateaxisangle(axisz, degtorad(-140)); float3 euleranglesb = bq.toeulerxyz();
both toeulerxyz {x=58.675510 y=33.600880 z=38.327244 ...} (when converted degrees).
the difference can see, quaternions identical, 1 negative. toeulerxyz wrong though, 1 should negative ({x=-58.675510 y=-33.600880 z=-38.327244 ...}) (bq)
aq is:
x 0.52576530 float y 0.084034257 float z 0.40772036 float w 0.74180400 float
while bq is:
x -0.52576530 float y -0.084034257 float z -0.40772036 float w -0.74180400 float
is error mathgeolib, or weird nuance, or maybe can explain me going on logically.
there additional scenarios not negative
axisx:
-0.71492511 y=-0.69920099 z=0.00000000
axisy:
0.69920099 y=-0.71492511 z=0.00000000
axisz:
x=0.00000000 y=0.00000000 z=1.0000000
code:
quat aq = quat::rotateaxisangle(axisx, degtorad(0)) * quat::rotateaxisangle(axisy, degtorad(0)) * quat::rotateaxisangle(axisz, degtorad(-90)); float3 euleranglesa = aq.toeulerxyz(); quat bq = quat::rotateaxisangle(axisx, degtorad(-180)) * quat::rotateaxisangle(axisy, degtorad(180)) * quat::rotateaxisangle(axisz, degtorad(90)); float3 euleranglesb = bq.toeulerxyz();
these both yield same quaternion!
x 0.00000000 float y 0.00000000 float z -0.70710677 float w 0.70710677 float
the quaternions -q , q different; however, rotations represented 2 quaternions identical. phenomenon described saying quaternions provide double cover of rotation group so(3). algebra see simple: given vector represented quaternion p, , rotation represented represented quaternion q, rotation qpq^{-1}
. on other hand, -qp(-q)^{-1} = -1qp(q)^{-1}(-1) = q(-1)p(-1)q^{-1} = qp(-1)^2q^{-1} = qpq^{-1}
, same rotation. quaternions don't commute, pq != qp
general quaternions, scalars -1 commute quaternions.
i believe toeulerxyz should same in both cases, appears be.
Comments
Post a Comment