MATLAB Answers

Multiplication of tranformation matrices gives strange result

2 views (last 30 days)
Jessica
Jessica on 27 Nov 2020
Answered: Bjorn Gustavsson on 27 Nov 2020
So, I´m tasked with doing multiple tranformations on a matrix, by way of permutation-matrices.
In math this is done by multiplying the permutation-matrices in the right order and then multiplying the result with original matrix.
The results I have gotten is strange, and when I reverse the order of the permutation-matrices the results are the SAME, and really should Not be.
B = Batman;
x = B(1,:);
y = B(2,:);
%plot(x,y,'.');
Rccw60=[1/2, sqrt(3/2); -sqrt(3/2), 1/2];
Refy=[-1, 0; 0, 1];
Rd1 = [x(:),y(:)] * Rccw60;
Rd2 = [x(:),y(:)] * Refy;
Rd60ref = Rd1 .* Rd2; % this is reflected, but should be angled at 120ccw(because of later reflection)
x2d = Rd60ref(:,1);
y2d = Rd60ref(:,2);
plot(x2d,y2d,'.')
title ('Combination of rotation 60ccw and reflection on y-axis')
Rdref60 = Rd2 .* Rd1; % this looks as it should
x2d2 = Rdref60(:,1);
y2d2 = Rdref60(:,2);
plot(x2d2,y2d2,'.')
title ('Combination of reflection on y-axis and rotation 60ccw')

  6 Comments

Show 3 older comments
Jessica
Jessica on 27 Nov 2020
In a previous question, when I got an answer, there was a "accept answer" button, but there is not one now???
So, I do accept this answer, but I do not know how without button...
Jessica
Jessica on 27 Nov 2020
So, answered that one.
Bruno, please answer this question, rather than commenting, then I can accept.

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 27 Nov 2020
Your decription does not match with what your code is doing (your code)
You take T1 on (x,y) data
You take T2 on (x,y) data
Then take elementwise product of those results. Elementwise (Hadamard) product is commutative.
Which is completely different than (your description)
apply (T1*T2) on (x,y) data
and (T2*T1) on (x,y).

  0 Comments

Sign in to comment.

More Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 27 Nov 2020
You have confused permutation-matrices with mirroring and rotation-matrices. They are not the same. Your Rccw60 is not (what I think) you think it is. To check that you have a sensible rotation-matrix (as one can colclude from your naming and description of what it should do), you should verify that the product of the matrix and its transpose is close to the identity-matrix:
Rccw60*Rccw60.'
Which clearly is not an identity-matrix.
Once you've fixed that (simply a typo), you should also take Bruno's advice into account.
HTH

  0 Comments

Sign in to comment.

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!