I was checking out the implementation of AffineTransform2D. It turns out to check whether the matrix is invertible, the condition that is checked is:
final double det = a.det(); /* similar to Jama, throw a RunTimeException for singular matrices. */ if ( det == 0 ) throw new RuntimeException( "Matrix is singular." );
which essentially implies that we would almost never see a case where matrix is singular.
Shouldn’t there be some sort of threshold here rather than checking against zero?
Moreover, the set(value, row, column) method right away checks for if the matrix is invertible with the new element, which is very odd.
So let’s say we’ve an original identity matrix, and I want to set to [[0, -1],[1, 0]]. So, I naturally start with set(0,0,0) and Bam! all of a sudden my code throws an exception saying matrix is not invertible, even though I’ve just only put one element inside! I know that the intent was to imitate Jama for some reason, but this behavior is unacceptable and dangerous!