akeil)  20070613 14:10
By: Andreas Keil ( 
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 or 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+m223)<0.001 or 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+m223)<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, Andreas. 
martinbaker)  20070614 08:00
By: Martin Baker ( 
Hi Andreas, Thanks for you comments on the website, its fun to do, some parts of the site aren't as good as I'd like but its improving all the time with the help of yourself an the people on this forum. You've given me some things to think about here. The first thing is: should we assume the input matrix is a pure, orthogonalised, rotation matrix and can we discount, for instance, a reflection matrix? I am tempted to include a optional calculation of the determinant at the start of the algorithm, if its +1 then that would be a good indication that its a rotation and if 1 its likely to be a reflection. If its not a rotation then an exception could be raised. So if its a rotation and not a reflection then I think that means we can discount the case with an odd number of negatives in the leading diagonal? So we only have to test the leading diagonal for: 3 plus ones = identity matrix 1 plus one and two minus ones = 180 degree rotation. I think thats what your suggested code does but I'll take a bit more time to work it through. I should have lots of time to work on the site soon so I'll look at this and the issues raised by Paolo de Leva and Xavier. Thanks, Martin 
akeil)  20070615 04:25
By: Andreas Keil ( 
Hi Martin, since the part of your web page we are talking about is on (proper) rotations, and since all other representations (except matrices) are not able to describe improper rotations / reflections, I would assume a pure rotation matrix. Anyways, there would be more checks necessary in order to decide whether a 3x3 matrix represents a rotation (R'*R = I and det(R) = 1 would be the complete test) and this in every of your conversion methods from matrix to anything. In my own C++ code, I included an assert(isRotationMatrix(R)) which is only evaluated in debug mode and does not affect performance in release mode. As to my proposed code change: You are absolutely right with your interpretation: Your conditions on this line of code so far are met by the identity matrix as well as 180deg rotations around one of the three basis axes. Since you only want to handle the identity matrix in the ifcase, you have to add this condition. The 180deg basis rotations are then handled by the elsecase. I would only sort out the identity case with the additional trace(M) = 3 check. Other additional checks would only increase the computation time here and if you wanted to stop on reflections, you would really have to do the full checks (R'*R=I and det(R)=1) at the very beginning of the conversion routine. Cheers, Andreas. 
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. 
Introductory Techniques for 3D Computer Vision by Emanuele Trucco, Alessandro Verri

This site may have errors. Don't use for critical systems.
Copyright (c) 19982023 Martin John Baker  All rights reserved  privacy policy.