techoe / ceres-solver

Automatically exported from code.google.com/p/ceres-solver
Other
0 stars 0 forks source link

QuaternionToAngleAxis - Unwanted result #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I executed some lines of code at bellow, and the returned AngleAxis value is 
[0.0312419 -3.16274 0.0340376],
the second value is greater than PI, it is unwanted result for me.

  double q[4], w[3];
  q[0] = -0.0107399;
  q[1] = 0.00987652;
  q[2] = -0.999836;
  q[3] = 0.0107603;
  ceres::QuaternionToAngleAxis( q, w );
  cout << w[0] << " " << w[1] << " " << w[2] << endl;
  sleep(2);

-- ceres Ver.: ceres-solver-1.1.1
-- OS: Ubuntu 11.10

My question is if the result is normal one?

Thank you!

Original issue reported on code.google.com by akc...@gmail.com on 16 Aug 2012 at 5:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I changed the line 188 of "rotation.h" as follow, and that working for my 
request.

//    const T k = T(2.0) * atan2(sin_theta, quaternion[0]) / sin_theta;
    const T a = T(2.0) * atan2(sin_theta, quaternion[0]);
    const T an = atan2( sin(a), cos(a) );
    const T k = an / sin_theta;

Still, I need some comments on this issue.

Thank you!

Original comment by akc...@gmail.com on 16 Aug 2012 at 12:47

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. This looks like a floating point overflow issue. I 
will look into today or hopefully tomorrow.

Original comment by sameerag...@google.com on 16 Aug 2012 at 2:51

GoogleCodeExporter commented 9 years ago

Original comment by sameerag...@google.com on 16 Aug 2012 at 5:50

GoogleCodeExporter commented 9 years ago
Its not a rounding error, but actually a bug in our conversion routine. Thanks 
for catching this and suggesting a solution. I came up with a slightly better 
(I think) solution which avoids two atan2 calls.

I have submitted a patch for review which fixes this, you can follow its 
progress  at

https://ceres-solver-review.googlesource.com/#/c/1571/

Original comment by sameerag...@google.com on 17 Aug 2012 at 5:18

GoogleCodeExporter commented 9 years ago
The change is submitted and live in the git repository on gerrit.

Original comment by sameerag...@google.com on 17 Aug 2012 at 9:33

GoogleCodeExporter commented 9 years ago
In the first post, the value of quaternion is given by the function 
QuaternionProduct:
  q[0] = -0.0107399;
  q[1] = 0.00987652;
  q[2] = -0.999836;
  q[3] = 0.0107603;

This value already implies that the theta is greater than PI, so I think this 
routine can also be improved to give a stable result.

Original comment by akc...@gmail.com on 18 Aug 2012 at 1:16

GoogleCodeExporter commented 9 years ago
I disagree. There are no constraints on the quaternions that the angle there be 
normalized. The result of the quaternion product is stable. Indeed, introducing 
a normalization there will create a discontinuity.

Original comment by sameerag...@google.com on 18 Aug 2012 at 7:22

GoogleCodeExporter commented 9 years ago
Thanks for your comment.

Original comment by akc...@gmail.com on 19 Aug 2012 at 5:45