Multiplication of tranformation matrices gives strange result
2 ビュー (過去 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')
6 件のコメント
採用された回答
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 で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!