필터 지우기
필터 지우기

I have a set of points and I need to rotate them of a certain angle. How can I do?

조회 수: 2 (최근 30일)
Federica
Federica 2024년 1월 25일
편집: Mann Baidi 2024년 1월 25일
I have a set of points with specific coordinates and I need to rotate them of a certain angle. This means that I have to:
  • translate all nodes so that the center becomes (0,0,0)
  • rotate ? degrees around z(?) by multiplying the coordinates with a rotation matrix
  • translate coordinates back to the original position
How can I do?

답변 (1개)

Mann Baidi
Mann Baidi 2024년 1월 25일
편집: Mann Baidi 2024년 1월 25일
Hi,
I understand you would like to translate the coordinates in xyz axes so that the centre '(0,0,0)'. You can try subtracting the original coordinates with their 'centroid'. Here's is an example code:
% Define the original set of 3D coordinates (XYZ)
original_points = [1, 2, 3; 4, 5, 6; 7, 8, 9];
% Calculate the centroid of the points
centroid = mean(original_points);
% Translate the points to center them at the origin
translated_points = original_points - centroid;
% Display the original and translated points
disp('Original Points:');
Original Points:
disp(original_points);
1 2 3 4 5 6 7 8 9
disp('Translated Points:');
Translated Points:
disp(translated_points);
-3 -3 -3 0 0 0 3 3 3
% Plot the points for visualization
figure;
scatter3(original_points(:, 1), original_points(:, 2), original_points(:, 3), 'o', 'DisplayName', 'Original Points');
hold on;
scatter3(translated_points(:, 1), translated_points(:, 2), translated_points(:, 3), 'x', 'DisplayName', 'Translated Points');
xlabel('X');
ylabel('Y');
zlabel('Z');
legend('Location', 'best');
grid on;
title('Translation to Center');

카테고리

Help CenterFile Exchange에서 3-D Scene Control에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by