i need help make the earth in the center, and the moon (lua) rotation and translation

1 次查看(过去 30 天)
clearvars;
set(0,'defaultTextInterpreter','latex');
set(groot, 'defaultAxesTickLabelInterpreter','latex')
set(groot, 'defaultLegendInterpreter','latex');
oLua = [4;4;4];
esc = 8;
% figure(1);
% xx = [0 0]; yy = [0 0]; zz = [-2*oLua 2*oLua];
% plot3(xx,yy,zz,'LineWidth',2); hold on; grid on;
% plot3(xx,zz,yy,'LineWidth',2);
% plot3(zz,yy,xx,'LineWidth',2);
% xlabel('$x$'); ylabel('$y$'); zlabel('$z$');
rLua = 2;
phi = 0:15:180;
theta = 0:15:360;
[theta,phi] = meshgrid(theta,phi);
LUA(3,25*13) = 0;
X = rLua .* sind(phi) .* cosd(theta);
Y = rLua .* sind(phi) .* sind(theta);
Z = rLua .* cosd(phi);
LUA(3,25*13) = 0; kk = 1;
for ii=1:13
for jj=1:25
LUA(:,kk) = [X(ii,jj);...
Y(ii,jj);...
Z(ii,jj)];
kk = kk + 1;
end
end
LUA = LUA + oLua;
for ang=0:5:360
LUA2 = rotacaoZ(LUA,ang);
scatter3(LUA2(1,:),LUA2(2,:),LUA2(3,:),2);
view([-13.8 24.9]);
axis([-esc esc -esc esc -esc esc]);
drawnow;
end
hold off;
function w = rotacaoZ(v,alpha)
Rot = [cosd(alpha) sind(alpha) 0 ;
-sind(alpha) cosd(alpha) 0 ;
0 0 1 ];
w = Rot * v;
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dialog Boxes 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by