Maths - Conversion Matrix to Axis Angle - Forum Discussion

By: Andreas Keil (akeil) - 2007-06-13 14:10
Hi Martin, 
first of all, thanks a lot for your effort in putting up this really huge website (in terms of contained information). I used a few of your conversion routines and during testing them I think, I found a small bug in the Matrix to AxisAngle conversion: 
The special case of a 180° rotation around one of the basis vectors is not handled correctly. The test 
Abs(m01+m10)<0.001 and Abs(m02+m20)<0.001 and Abs(m12+m21)<0.001 
if (Math.abs(m01+m10)<epsilon and Math.abs(m02+m20)<epsilon and Math.abs(m12+m21)<0.1) 
as you put it in the Java code, does not only detect identity matrices but also 180° rotations around the x, y, or z axis. My proposed correction would be 
Abs(m01+m10)<0.001 and Abs(m02+m20)<0.001 and Abs(m12+m21)<0.001 and Abs(m00+m11+m22-3)<0.001 
if (Math.abs(m01+m10)<0.001 and Math.abs(m02+m20)<0.001 and Math.abs(m12+m21)<0.001 and Math.abs(m00+m11+m22-3)<0.001) 
respectively. This ensures that really only identity matrices are handled by this case and matrices with one 1 and two -1s are taken care of in the 180° case instead. 
There might be better criteria for detecting identity matrices but this one only adds one more check to the existing code. Let me know what you think about it. 
Thanks again, 

metadata block
see also:


Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Introductory Techniques for 3-D Computer Vision by Emanuele Trucco, Alessandro Verri


This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.