Sorry I can't recommend a modern book (it is many years since I learnt this stuff). I'd see if there are any recommendations on your university's website/ notes for your course.
Before writing a program though I'd consider if there's a simpler solution - like perhaps making a small poster that summarises the various 2x2 matrices and what they look like. This might be simple but effective.
But if the requirement is still to write a program then I'd think about it for a while. If the input matrix is [a b; c d] then I could check to see if it's the identity matrix by writing
Code:
if (a==1.0 && b==0.0 && c==0.0 && d==1.0) {
print "Identity matrix"
} else {
// Check for other types of matrix
}
However the above approach would not catch the case where a matrix is
almost the identity matrix.
The following approach would take more effort to program BUT would be more robust to small errors. For each type of transformation matrix produce a number that indicates how close the matrix is to being that type. Think of this number as a "certainty" or "error" amount. For example...
Code:
// Check for identity matrix
error = fabs(a-1.0) + fabs(b) + fabs(c) + fabs(d-1.0);
The function fabs() is for absolute value, or modulus |x|, of a floating point number. The above error variable would be zero if the input matrix was exactly the identity matrix. But if it was close to being the identity matrix then the error would be small.
At the end of the code I'd sort the results by the error amounts, and perhaps print out the top two results (if the error amounts are close)...
Code:
Your input matrix [ 1.0001 0 ; 0 1.0 ] seems to be:-
an identity matrix with error 0.0001
OR a scale transformation matrix with scale factor 1.00005, with error(certainty) 0.4
The next step up from this would be writing code that can handle the generic case of any input matrix, one that might be several transforms happening at the same time. To do this you'd need to consider the resultant matrix you'd get from <x-scale> * <y-scale> * <x shear> * <y shear> * <rotation> and equate the result of this to the [a b; c d] input vector. Hopefully after solving a nasty simultaneous equation you'll obtain values for the scales, shears and rotation. But you'd probably also want to consider doing these in a different order, maybe starting with rotation this time <rotation> * <x-scale> * <y-scale> * <x shear> * <y shear> simply because some of the numbers might turn out to be nicer doing it this way around. Probably not worth the effort! I'd stick to the poster idea