Surface rotation in 3d

2 次查看(过去 30 天)
rem9818
rem9818 2019-8-1
编辑: rem9818 2019-8-2
Hello,
I have a problem to rotate a surface in 3D. I would like to rotate an ellipsoid (S) in the three directions but it doesn't work.
When I run the code below just the third rotation is taken into account.
Thank you for your help!
rotate(S, [1 0 0], 180*roll(i)/pi, center);
rotate(S, [0 1 0], 180*pitch(i)/pi, center);
rotate(S, [0 0 1], 180*yaw(i)/pi, center);
  4 个评论
darova
darova 2019-8-2
Can you please show?
rem9818
rem9818 2019-8-2
编辑:rem9818 2019-8-2
I managed to display the new surfaces but their positions changed
for i=1:101
[x, y, z] = ellipsoid(X(i),Y(i),Z(i),b,a,a);
S = surf(x,y,z);
S.FaceColor = 'white';
S.EdgeColor = 'white';
title('Position and orientation of fibers in the water channel')
xlabel('X')
ylabel('Y')
zlabel('Z')
center = [X(i) Y(i) Z(i)];
rotm = eul2rotm([roll(i) pitch(i) yaw(i)],'XYZ');
%rotate(S, [1 1 1], 180*roll(i)/pi, center);
%rotate(S, [0 1 0], 180*pitch(i)/pi, center);
%rotate(S, [0 0 1], 180*yaw(i)/pi, center);
Matrix_X = S.XData;
Matrix_Y = S.YData;
Matrix_Z = S.ZData;
Vec_X = Matrix_X(:);
Vec_Y = Matrix_Y(:);
Vec_Z = Matrix_Z(:);
V = [Vec_X Vec_Y Vec_Z];
s = size(V);
for j=1:s(1)
NewV = rotm*V';
end
NewM_X = vec2mat(NewV(1,:),21);
NewM_Y = vec2mat(NewV(2,:),21);
NewM_Z = vec2mat(NewV(3,:),21);
S2 = surf(NewM_X,NewM_Y,NewM_Z, 'EdgeColor', 'r');
hold on
set(gca,'color','k')
axis equal
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geodesy and Mapping 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by