资源描述:
《飞越北极问题程序设计_地球》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、飞越北极问题程序设计程序设计:余时伟电子科技大学应用数学学院2008.3.25第一条航线:北京——上海——东京——旧金山——纽约航点纬度经度北京北纬40o东经116o上海北纬31o东经122o东京北纬36o东经140o旧金山北纬37o西经123o纽约北纬41o西经76o第二条航线:北京——纽约tic%timebegincleartheta=[40,31,36,37,41,40]/180*pi;fai=([116,122,140,-123,-76,116]+180)/180*pi;R=6400+10;x=R*
2、cos(theta).*cos(fai);y=R*cos(theta).*sin(fai);z=R*sin(theta);fori=1:6cor{i}=[x(i),y(i),z(i)];endfori=1:5th{i}=acos(dot(cor{i},cor{i+1})/(norm(cor{i})*norm(cor{i+1})));endA=R*[th{1},th{2},th{3},th{4}];distance_1={'绕飞航程长度',fix(sum(A));'直飞航程长度',fix(th{5}*R)};
3、%航程长度计算distance_2={'北京到上海','上海到东京','东京到旧金山','旧金山到纽约'fix(A(1)),fix(A(2)),fix(A(3)),fix(A(4))};theta2=(-90:5:90)*pi/180;fai2=(-180:5:180)*pi/180;X=R*cos(theta2)'*cos(fai2);Y=R*cos(theta2)'*sin(fai2);Z=R*sin(theta2)'*ones(size(fai2));load('topo.mat','topo','t
4、opomap1');whostopotopomap1;4contour(0:359,-89:90,topo,[00],'b');axisequalboxonset(gca,'XLim',[0360],'YLim',[-9090],...'XTick',[060120180240300360],...'Ytick',[-90-60-300306090]);holdonimage([0360],[-9090],topo,'CDataMapping','scaled');colormap(topomap1);cl
5、aresetaxissquareoffprops.AmbientStrength=0.1;props.DiffuseStrength=1;props.SpecularColorReflectance=0.5;props.SpecularExponent=20;props.SpecularStrength=1;props.FaceColor='texture';props.EdgeColor='none';props.FaceLighting='phong';props.Cdata=topo;surface(
6、X,Y,Z,props);%画地球表面并进行光照和材质处理axisoffaxisequallight('position',[-80003009200]);light('position',[80009000-9200]);light('position',[800-500200]);light('position',[85005000-8600],'color',[.6.2.2]);view(-30,59)holdontheta3=31/180*pi;%成都地理位置fai3=103/180*pi+pi;x
7、3=R*cos(theta3).*cos(fai3);y3=R*cos(theta3).*sin(fai3);z3=R*sin(theta3);theta4=48.194/180*pi;%伦敦地理位置fai4=2/180*pi+pi;x4=R*cos(theta4).*cos(fai4);y4=R*cos(theta4).*sin(fai4);4z4=R*sin(theta4);scatter3([x(1:5),x3,x4,0,0],[y(1:5),y3,y4,0,0],[z(1:5),z3,z4,R,-R
8、],'filled')%画城市分布t=(0:20)/20;fori=1:4%画绕飞各城市之间航线X=(1-t)*x(i)+t*x(i+1);Y=(1-t)*y(i)+t*y(i+1);Z=(1-t)*z(i)+t*z(i+1);r=sqrt(X.*X+Y.*Y+Z.*Z);X=R*X./r;Y=R*Y./r;Z=R*Z./r;holdonplot3(X,Y,Z,'r','LineWidth',2)endX=(1-