简体   繁体   English

如何将 3D surf plot 和 comet3 plot 组合到 Z8F6823ABD383A341F0D7EFBBBB

[英]How to combine a 3D surf plot and a comet3 plot in MATLAB?

I'm writing a code to plot the circular orbit of a satellite (created using comet3() function) around a 3d model of the Earth (created using surf() and set() functions).我正在编写一个代码 plot 卫星的圆形轨道(使用 comet3() 函数创建)围绕 3d Z20F35E630DAF44DBFA4C3F68F5399(D8CZ of the Earth) 和 set 函数(创建)。 The problem is that I can't seem to find a way to get them together in the same plot.问题是我似乎无法找到将它们放在同一个 plot 中的方法。 I have tried using hold on and hold off but that doesn't seem to work either.我尝试过使用 hold on 和 hold off 但这似乎也不起作用。 I'm pasting the MATLAB code below for reference.我在下面粘贴 MATLAB 代码以供参考。

Edit: All the other functions like sv_from_coe(), odeset, etc. are working perfectly, the only place I'm facing issue is combining the plots from comet3() and set().编辑:sv_from_coe()、odeset 等所有其他函数都运行良好,我面临的唯一问题是结合 comet3() 和 set() 的图。

G = 6.67E-11;
Me = 5.976E24;

coe = [6776, 0.0005638, 2.0543, 0.9, 5.549, 0];
[r, v] = sv_from_coe(coe);
rv = [r v];

opt = odeset('RelTol', 1e-6, 'AbsTol', 1e-6);
[t,X] = ode45(@rate, [0 2*1.5*3600], rv, opt);

[x,y,z] = sphere;
r_earth = 6378*1000;

figure
hs1 = surf(x*r_earth,y*r_earth,-z*r_earth);
cdata = imread('1024px-Land_ocean_ice_2048.jpg');
alpha = 1;

hold on
axis equal
comet3(X(:,1), X(:,2), X(:,3))
set(hs1, 'FaceColor', 'texturemap', 'CData', cdata, 'FaceAlpha', alpha, 'EdgeColor', 'none')

You just have to reverse the order, first plot the earth and set the texture.您只需颠倒顺序,首先 plot 地球并设置纹理。 Then use comet3 to animate the trajectory:然后使用comet3对轨迹进行动画处理:

% earth
[x,y,z] = sphere;
r_earth = 6378*1000;

% some simple trajectory
phi = 0:0.01:2*pi;
r_orbit = r_earth + 408*1e3; % ISS orbit height
xv = r_orbit * cos(phi);
yv = r_orbit * sin(phi);
zv = zeros(size(yv));

% draw figure
figure(1); clf;
ax = axes;

% first plot the earth and set texture
hs1 = surf(x*r_earth,y*r_earth,-z*r_earth);
alpha = 1;
cdata = imread("Land_ocean_ice_2048.jpg");
set(hs1, 'FaceColor', 'texturemap', 'CData', cdata, 'FaceAlpha', alpha, 'EdgeColor', 'none')
hold on
axis equal

% finally, animate using comet3
comet3(xv,yv,zv)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM