3D animate plot of satellite in orbit around Earth
55 次查看(过去 30 天)
显示 更早的评论
Hello.
I am developing an app with app designer and I need to animate the plot of a satellite on a fixed orbit.
In the following, a simplified version of what I've always used:
C = imread('map.jpg');
[x, y, z] = ellipsoid(0,0,0, 6378.135, 6378.135,6356.750,1E2);
surf(x,y,z,circshift(flip(C),[0,ceil(size(C,2)/360)]), 'FaceColor', 'texturemap','EdgeColor','none');
axis equal;
hold on;
plot3(orbit(1,:),orbit(2,:),orbit(3,:),'linewidth',2,'color', .6*ones(1,3));
position = scatter3(orbit(1,1),orbit(2,1),orbit(3,1),'filled','color', 'r');
for j = 2 : size(position,2)
position.XData = orbit(1,j);
position.YData = orbit(2,j);
position.ZData = orbit(3,j);
pause(0.1);
end
uif = uifigure;
earth = geoglobe(uif);
hold(earth,'on');
geoplot3(earth,latitude,longitude,altitude,'linewidth',2,'color', .6*ones(1,3));
position = geoplot3(earth,latitude(1),longitude(1),altitude(3,1),'ro');
for j = 2 : length(altitude)
position.LatitudeData = latitude(j);
position.LongitudeData = longitude(j);
position.HeightData = altitude(j);
pause(0.1);
end
Unfortunately I faced two major problems:
- The Marker can't be set as 'filled' and I don't really like it this way
- The pause command doesn't work properly as the time elapsed between cycles is much larger
- The view of the globe is automatically updated and when the user tries to rotate the view with the figure tools, the values of campos are reset to a reference view automatically
The second problem can be fixed by setting campos before the loop.
The third problem is related to the automatic view update of geoglobe and I did not find a solution on how to disable it.
I am confident that disabling the automatic view update would also solve the second problem.
A side problem is the flickering transition given by the loop update, but I hope I can solve this with timer.
Is there a simple solution to these three problems that you might be aware of?
Are there any alternatives to obtain animated fancy plot like the second one?
Thanks
0 个评论
采纳的回答
Vidip Jain
2023-3-20
Regarding your first problem, the “geoplot3” function does not have an option to set the marker as filled. However, you can use the “scatter3” function instead of “geoplot3” to create filled markers on the globe.
Regarding your second problem, using the “pause” command in a loop can be problematic as the time elapsed between iterations may not be exactly the time specified in the “pause” command due to system timing and processing delays. Instead, you can use the “tic” and “toc” commands to measure the elapsed time between iterations and adjust for the processing time.
Regarding your third problem, the “geoglobe” function automatically updates the view when you plot data on the globe. One possible solution is to set the “XLim”, “YLim”, and “ZLim” properties of the axis to fixed values before plotting data on the globe. This will prevent the automatic view update from resetting the camera position.
2 个评论
leka0024
2023-12-15
@Vidip Jain how can scatter3 be used with a geoglobe plot?
If I make a scatter3 and try to set its handle.Parent to be the GeographicGlobe handle, an error says that this is not allowed.
leka0024
2023-12-15
Also, why is geoglobe() only allowed to be in a uifigure?
I can do a gca(uif) and get a handle to the axes, with lots of properties, but I'm not sure that this is actually valid?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!