Rotation Matrix 3D
Mostrar comentarios más antiguos
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 comentarios
Jan
el 25 de Jun. de 2019
"three 240x320 matrices (x, y, z, which are the cartesian points..." - this is not clear to me. Which of the x, y and z components are included in the matrices in which dimension?
I would replace cosd(90) by 0 and sind(90) by 1.
rotz = [cosd (90) -sind (90) 0; sind (90) cosd (90) 0; 0 0 0 1 ];
% ^ ^ ^ ^ 4 elements?!
Do you only want to move the elements inside the matrix? Then tranpose and flip will help you.
Bjorn Gustavsson
el 25 de Jun. de 2019
Editada: Bjorn Gustavsson
el 25 de Jun. de 2019
Nah, don't constrain the rotation-matrix like that - sooner or later the OP will need to rotate something an arbitrary angle around z - then this version is way easire to generalize instead of a hard-coded variant - if something change to radians from degrees.
Jan
el 25 de Jun. de 2019
@Bjorn: Maybe the OP wants to rotate the matrix elements, not the X and Y values. I'm puzzled by the current descriptions. It does not look like "three 240x320 matrices" are the correct operand for a [3x3] rotation matrix.
Bjorn Gustavsson
el 25 de Jun. de 2019
@Jan, fair point, I guessed away from the 3x3 rotation matrix and "decided" that there were 240x320 points with x, y, and z - coordinates stored in 3 separate matrices...
Schiopu Robert
el 25 de Jun. de 2019
Bjorn Gustavsson
el 25 de Jun. de 2019
What part of my solution doesn't do it for you?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Model Import en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!