Rotation Matrix 3D

조회 수: 6 (최근 30일)
Schiopu Robert
Schiopu Robert 2019년 6월 25일
댓글: Schiopu Robert 2019년 6월 25일
Hello ,
I want to try to spin a matrix, but I can not. I have three 240x320 matrices (x, y, z, which are the cartesian points of a stereo camera scan) and have done 4 scans (front, right, left, back) and I want to rotate the Cartesian arrays with 90 degrees, 180 degrees in the back and 270 left to create a 360 degree view. and the rotation matrix, from what I read, has the size of 3x3 (rotate = [cosd (90) -sind (90) 0; sind (90) cosd (90) 0; 0 0 0 1]). I tried the following:
rotz = [cosd (90) -sind (90) 0; sind (90) cosd (90) 0; 0 0 0 1 ];
for i = 1:240
for j = 1:320
[0 0 x11(i,j)] = rotz.*[0 0 x11(i,j)];
end
end
or :
for i = 1:240
for j = 1:320
x11(i,j) = rotz.*x11(i,j);
end
end
Can anyone tell me how can I do that multiplication? Or if there is another option to rotate the matrix?
Thank you have a good day
  댓글 수: 6
Schiopu Robert
Schiopu Robert 2019년 6월 25일
@Jan :Excuse me, there are 3 matrices with dimensions of 240x320, these matrices are Cartesian coordinates. After scanning, the program gave me a depth matrix of 240x340, and with azimuth and elevation, I found out the Cartesian coordinates, which are these 3 arrays (x, y, z). and the rotation matrix in the last line has 3 elements, just wrong and I added a zero when I copied the code. The rotation matrix is rotate = [cosd (90) -sind (90) 0; sind (90) cosd (90) 0; 0 0 1]; , but it still does not work
Bjorn Gustavsson
Bjorn Gustavsson 2019년 6월 25일
What part of my solution doesn't do it for you?

댓글을 달려면 로그인하십시오.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2019년 6월 25일
Maybe something like this for your coordinates:
r_all = [x(:),y(:),z(:)];
r_rotated = (rotz*r_all')';
Xr = x;
Yr = y;
Zr = z;
Xr(:) = r_rotated(:,1);
Yr(:) = r_rotated(:,2);
Zr(:) = r_rotated(:,3);
HTH
  댓글 수: 1
Schiopu Robert
Schiopu Robert 2019년 6월 25일
Thank you , this is work !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Import에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by