![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196417/image.png)
Rotate the 3D point data about Z axis , and // OX OY
조회 수: 2 (최근 30일)
이전 댓글 표시
Let's say: I have matrix A=[x y z] with ~60.000 point data . Please see attachment file, and figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196405/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196406/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196407/image.jpeg)
Question: How can I rotate the 3D point data about Z axis , and // OX OY (as illustration)? Additional, we don't know the rotation angel. I do hope the result will be like below figure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196408/image.jpeg)
댓글 수: 0
채택된 답변
Bruno Luong
2018년 11월 24일
편집: Bruno Luong
2018년 11월 24일
xyz=load('data.txt');
xyzc = mean(xyz,1);
xyzr = xyz - xyzc;
[~,~,V] = svd(xyzr,0);
% Rotate 90°: so that the long size // to y_axis
V = V*[0 -1 0;
1 0 0;
0 0 1];
xyzr = xyzc + xyzr*V;
close all
hold on
plot3(xyz(:,1),xyz(:,2),xyz(:,3),'.b');
plot3(xyzr(:,1),xyzr(:,2),xyzr(:,3),'.r');
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
view(3)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196417/image.png)
댓글 수: 2
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!