use faster unit quaternion rotation #625
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
It seems that original
ceres::UnitQuaternionRotatePointis based on idea: convert to rotation matrix, then rotate. It seems quite inefficient, since obtained rotation matrix is not cached anywhere and had to be recomputed each timeUnitQuaternionRotatePointis called.Updated code uses ideas from here:
https://fgiesen.wordpress.com/2019/02/09/rotating-a-single-vector-using-a-quaternion/
The same code also implemented in Eigen v.3.3.7 , under
Eigen::Quaternion::_transformVector().The code was tested under context of Structure-From-Motion tasks inside bundle adjustment cost functions with COLMAP code base, and behaves quite well.
I did not measure the execution time, but when by counting multiply-adds original
ceres::UnitQuaternionRotatePointhas around 24(21 if not counting negations) multiplications and 18 additions, while proposed one has 15 multiplications and 15 additions.