Rotate the 3D point data about Z axis , and // OX OY

1 visualización (últimos 30 días)
ha ha
ha ha el 24 de Nov. de 2018
Comentada: Uriel Angel el 3 de Mzo. de 2021
Let's say: I have matrix A=[x y z] with ~60.000 point data . Please see attachment file, and figure:
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.

Respuesta aceptada

Bruno Luong
Bruno Luong el 24 de Nov. de 2018
Editada: Bruno Luong el 24 de Nov. de 2018
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)
  2 comentarios
ha ha
ha ha el 24 de Nov. de 2018
Thanks @Bruno Luong. I follow your code. But there are small error as the below figure. Do you know how to correct it?
Untitled.png
Uriel Angel
Uriel Angel el 3 de Mzo. de 2021
Excellent!!!
Really thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by