Orientation, Position, and Coordinate Convention
이전 댓글 표시
I want to change my camera pose from xyz coordinate system(where x-forward direction, y left and z up) to zyx coordinate system ( z-forward y- down and x left) My camera pose is described in an homogenous matrix. Let's take this matrix as an example:
Camera = [ 1 0 0 1,
0 1 0 2,
0 0 1 3,
0 0 0 1]
i created this function which rotate the matrix but i'm not sure if it's working correctly. I mean the rotation needs to be supported the the correct translation right ? :
function rotated_matrix = rotate_homogeneous_matrix(original_matrix, axis, angle_degrees)
% Ensure the matrix is 4x4
if size(original_matrix) ~= [4, 4]
error('Input matrix must be a 4x4 homogeneous matrix');
end
% Convert angle to radians
angle_radians = deg2rad(angle_degrees);
% Create a copy of the matrix to avoid modifying the original
rotated_matrix = original_matrix;
% Define rotation matrices based on the specified axis
if axis == 'X'
rotation_matrix = [
1, 0, 0, 0;
0, cos(angle_radians), -sin(angle_radians), 0;
0, sin(angle_radians), cos(angle_radians), 0;
0, 0, 0, 1
];
elseif axis == 'Y'
rotation_matrix = [
cos(angle_radians), 0, sin(angle_radians), 0;
0, 1, 0, 0;
-sin(angle_radians), 0, cos(angle_radians), 0;
0, 0, 0, 1
];
elseif axis == 'Z'
rotation_matrix = [
cos(angle_radians), -sin(angle_radians), 0, 0;
sin(angle_radians), cos(angle_radians), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1
];
else
error('Invalid axis. Use ''X'', ''Y'', or ''Z''.');
end
% Apply rotation
rotated_matrix = rotated_matrix * rotation_matrix;
end
% Example usage
pose = rotate_homogeneous_matrix(Camera, "Y", 90)
pose = rotate_homogeneous_matrix(pose, "Z", -90)
I'm only rotating the axes. Do I need to change the order of the translation vector element? Does this function implementation satisfy the target.


채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Process Point Clouds에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
