資源簡介
在matlab環境下寫的三維地球模型,可以自己旋轉,并可模擬衛星運動軌跡

代碼片段和文件信息
%%?Textured?3D?Earth?example
%%?Options
space_color?=?‘k‘;
npanels?=?72;???
%?Number?of?globe?panels?around?the?equator?deg/panel?=?360/npanels
alpha???=?1;?
%?globe?transparency?level?1?=?opaque?through?0?=?invisible
%?Earth?texture?image
%?Anything?imread()?will?handle)?but?needs?to?be?a?2:1?unprojected?globe
%?image.
%?This?is?from?NASA‘s?Visible?Earth?site?(http://visibleearth.nasa.gov/)
%?The?actual?image?link?will?likely?move?over?time.?This?one?is?the?260KB
%?version?from?this?page:?http://visibleearth.nasa.gov/view_rec.php?id=2430
%?image_file?=?‘http://veimages.gsfc.nasa.gov/2430/land_ocean_ice_2048.jpg‘;
image_file?=?‘globe.jpg‘;
%?Mean?spherical?earth
erad????=?6371008.7714;?
%?equatorial?radius?(meters)
prad????=?6371008.7714;?
%?polar?radius?(meters)
erot????=?7.2921158553e-5;?
%?earth?rotation?rate?(radians/sec)
%%?Create?figure
figure(‘Color‘?space_color);
hold?on;
%?Turn?off?the?normal?axes
set(gca?‘NextPlot‘‘add‘?‘Visible‘‘off‘);
axis?equal;
axis?auto;
axis?vis3d;
%%?Create?wireframe?globe
%?Create?a?3D?meshgrid?of?the?sphere?points?using?the?ellipsoid?function
[x?y?z]?=?ellipsoid(0?0?0?erad?erad?prad?npanels);
globe?=?surf(x?y?-z?‘FaceColor‘?‘none‘?‘EdgeColor‘?0.5*[1?1?1]);
%%?Texturemap?the?globe
%?Load?Earth?image?for?texture?map
cdata?=?imread(image_file);
%?Set?image?as?color?data?(cdata)?property?and?set?face?color?to?indicate
%?a?texturemap?which?Matlab?expects?to?be?in?cdata.?Turn?off?the?mesh?edges.
set(globe?‘FaceColor‘?‘texturemap‘?‘CData‘?cdata?‘FaceAlpha‘?alpha?‘EdgeColor‘?‘none‘);
%%?view
m=200;
n=30;
view(mn)
%改變初始圖形的視角,第一個參數是地球沿極軸旋轉的角度,為0時,美洲正對著我們,角度為正時向東
%第二個參數為地球傾斜的角度,為0時赤道正對著我們,角度為正時,地球向南傾斜
%旋轉;
disp(‘請輸入您的操作按Enter鍵結束:‘);
ope=input(‘‘‘s‘);
if?ope==‘move‘
????disp(‘地球正在旋轉...‘);
????disp(‘請按Ctrl+C鍵退出‘);
????while?1
????????for?i=1:1800
????????????j=m+i*0.2;
????????????if(j>360)
????????????????j=j-360;????
????????????end
????????????view(jn);
????????????pause(0.01);?
????????end
????end
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????312728??2012-03-15?19:08??earth\earth.jpg
?????文件???????2180??2012-04-14?12:35??earth\earth.m
?????文件????1398329??2008-09-03?16:20??earth\globe.jpg
?????文件?????972434??2012-03-15?19:28??earth\moon.jpg
?????文件???????1311??2012-04-14?12:50??earth\satellite.m
?????目錄??????????0??2012-05-06?16:38??earth
-----------?---------??----------?-----??----
??????????????2686982????????????????????6
評論
共有 條評論