Multiplication of tranformation matrices gives strange result
조회 수: 6 (최근 30일)
이전 댓글 표시
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')
채택된 답변
Bruno Luong
2020년 11월 27일
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
추가 답변 (1개)
Bjorn Gustavsson
2020년 11월 27일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!