Classification of linear transformations

Darya

Junior Member
Joined
Jan 17, 2020
Messages
154
I'm not in a uni yet but I've been working on a program to help me visualise matrix multiplication in the future. A piece that I might also want to add is a function that would classify linear transformation by looking at applied 2x2 matrix (it's 2D). E.g I'd like to be able to classify Rotation, Shear, Projection, Reflection, Scaling. Could we determine a characteristic that would distinguish one type of matrix from another?
 
Are you thinking of classifying a general matrix, one that could be a combination of Rotation, Shear, etc? There might be multiple ways to obtain the same 2D matrix. For example x-reflection followed by y-reflection would be the same as a single 180° rotation.

Or would you be supplying a matrix that is just ONE of rotation, shear, etc?
 
Are you thinking of classifying a general matrix, one that could be a combination of Rotation, Shear, etc? There might be multiple ways to obtain the same 2D matrix. For example x-reflection followed by y-reflection would be the same as a single 180° rotation.

Or would you be supplying a matrix that is just ONE of rotation, shear, etc?

Thank you so much for reply!

I figure this kind of question may not be too appropriate to ask on this forum, the project is finished now but I'm still interested in how I can classify a matrix that isn't a combination but just EITHER shear or rotation etc. without using neural networks (i.e. i would need to know patterns to make an algorithm). If you could share any links or names of books that could help me, I'd really appreciate it:)

Have a nice day!
 
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 :)
 
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 :)

Oh, now I see how complicated it gets... Thank you for your time and such a cool idea!
You've probably saved me from a couple of mental breakdowns on my way to making this work out:)
 
Top