Code covered by the BSD License  

Highlights from
heli2

image thumbnail
from heli2 by Andreas Plattner
heli2 is a helicopter flight simulator.

heli2(action)
function heli2(action)
% HELI2 helicopter flight simulator
%   HELI2 starts the Helicopter flight simulator. The landscape is based
%   on the function 'peaks', and is built in the subfunction 'scenery4'.
%   There are some parameters to change the flying properties. An Instrumental
%   Panel provides information on location, heading, speed, horizon and altitude.
%   The dafault values of flying parameters should give a good flying behavior,
%   but however, you can change these parameters as you want. Don't hesitate to
%   play a little bit.
%
% Modification Log:
%   created: may 2002 by A. Plattner
%   last revision: 11 nov 2003
%   email: andreas.platter@skyguide.ch
%
%FLYING:
%   If you start, you will see a planet and his moon in a virtual landscape.
%   The mouse pointer is automatically centered in the middle of the viewing
%   window.  This represents the control stick in the vertical position.
%   Moving the mouse up and down will change the altitude. Moving the mouse
%   right and left, will change the direction. The max. altitude is 26.
%
%   In the figure 'COCKPIT' you will find all the navigation instruments you 
%   need. You see the figure 'LOCATION', which shows you the current 
%   location. In the middle figure, you can see the 'HEADING' and the 'SPEED'.
%   On the right side, you can find the figure 'HORIZON' and 'ALTITUDE'. Don't
%   forget to speed up with the key 'q' on the keyboard when you start. With
%   the key 'a', you can also fly backwards, like a helicopter. Try to fly
%   between the planet and the moon with the heading North. Make a right turn
%   out of the landscape only with the navigatin tools and make an approach
%   to the radar station in North-East. Then go and try to land in front of the
%   igloo. Now enjoy a roundtrip in a virtual landscape.
%
%   At any time during flight, the following keys may be pressed for:
%
%       q: speed up
%       a: slow down
%       w: view more up
%       s: view more down
%       y; set Pointer location to center
%       x: exits the game
%       n: night flight
%       t: twilight flight
%       d: day flight
%
%LANDSCAPE
%   subfunction 'SCENERY'
%   The landscape is build by 'mesh' or 'surf'. The problem is perhaps the
%   speed. You my have a much more powerful computer and change the scenery
%   do 'SURF'. The landscape is build in the sub function 'SCENERY', which is
%   based on the matlab function 'peaks'. With the parameter 'LEPT', you can
%   dilute the number of z values, so the speed behavior is much better.
%   However, a less accurate will result.
%
%   subfunction 'SPHHELI'
%   The subfunctin 'SPHHELI' generates a Sphere (Planet/Moon/Igloo). You can also
%   use this subfunction for another reasons like as 'SPERE' in matlab.
%   In addtional, you can place the sphere where you want in a x y z location,
%   and generate also sphere segments.
%
%HOW CAN I change properties scenery?
%   If you want the play with the landscape surface, you can do it like as fellow.
%                 original setting      possible settings
%
%    light        = 'none';           % 'none', 'flat', 'gouraud', 'phong'
%    caml         = ('(''none'')');   % 'none', 'right', 'left', 'headlight'
%    shade        = ('(''none'')');   % 'none', 'flat', 'faceted', 'interp'
%    groundstyle  = 'mesh';           % 'mesh', 'surf'
%
%HOW CAN I speed up ?
%   A compromise is, not do activate 'caml' e.g. 'camlight right', this seems
%   do by a processing power cosumtion function.
%
%   Another possibility is do set the 'figurefac' to 4
%   figurefac    = 4;                 % 5   factor of the figure size in x/8
%
%   The figure will be smaller, but the processing speed will incrase
%    
%   The next possibility is to set the dilute factor
%   lept         = 3;                 % 2   dilute faktor of the scenery matrix
%
%   The reault is, that you can see less details, but the speed will also
%   incrase. The dilute factor 1 will gibe you the best scenery, but the
%   processing speed will decrease.
%
%GENERAL INFOS
%   If you can't see the landscape any more, don't wory about, You see on
%   your instruments your current position and the heading. So you can
%   navigate in any 'blind' manner back in the scenery.
%
%   The display screen is automatically scaled by the parameter 'FIGUREFAC'.
%   A god value is 5. 8 means full screen, but then, you can't see the nav.
%   instruments. Please, move the command window out of the place of the
%   scenery and the Cockpit figures.
%
%   The inspiratin do write a flight simulater, I become from the Flight simulator
%   written by Daniel Call, submittet 1999-01-01. Thanks him, for initialze
%   my inspiration.

% FUTURE PLANS:
% free loading landscapes
% autopilot: by click the mouse to a object
% Input the most important parameter by varargin
% Record and replay tracks
% side step maneuvering
% Helicopter sound (has somebody such a wav?)

%MATLAB SETINGS
    clc, close all; clear all
    format bank; format compact
    
%FLYING PARAMETER properties          % default values
    height_t     = 8;                 % 8     initializing target heigth
    heigth_tmax  = 16;                % 16    def maximun height
    heigth_tmin  = -20;               % -20   def minimum height
    height_l     = .15;               % .15   initializing location heigth   
    heigth_lmax  = 26;                % 26    def maximun height
    heigth_lmin  = .15;               % .15   def minimum height
    velocity     = 0.0;               % 0.0   initializing velocity
    velocity_max = 2;                 % 2     def maximum velocity
    velocity_min = -.3;               % -.3   def minimum velocity
    view_angle   = 20;                % 20    def view angle
    sidefac      = 18;                % 18    emphasis the CameraUpVector
    anglefac     = 1.5;               % 1.5   emphasis the cursur senitvity
    angletol     = 0.1;               % 0.1   anlge tolerance for 0 in the center
    alttol       = 0.1;               % 0.1   altitude tolerance for 0 in the center
    r0           = 80;                % 80    def target view radius
    x0           = -20;               % -20   def the starting point x0 (x0 -> North)
    y0           = 0;                 % 0     def the starting point y0
    lept         = 2.0;               % 2     dilute faktor of the scenery matrix
%   lept         = 2.5;               % 2     dilute faktor of the scenery matrix
    altfac       = .5;                % .5    factor for climb and decend rate
    mountampl    = 2;                 % 2     amplifies the mountins-hight
%   figurefac    = 5;                 % 5     factor of the figure size in x/8 in
    figurefac    = 4;                 % 5     factor of the figure size in x/8 in
                                      %       relation to the screen size
%FIGURE  properties scenery
    C            = 32;                % 32    deep of the color map
    cmapS        = summer(C);         %       color map 'scenery'
    cmapP        = hot(C);            %       color map 'planet' and 'moon'
    cmapR        = cool(C);           %       color map 'Radar'
    cmapI        = white(C);          %       color map 'Igloo'
 %  light        = 'gouraud';         %       'none', 'flat', 'gouraud', 'phong'
    light        = 'none';            %       'none', 'flat', 'gouraud', 'phong'
 %  caml         = ('(''left'')');    %       'none', 'right', 'left', 'headlight'
    caml         = ('(''none'')');    %       'none', 'right', 'left', 'headlight'   
 %  shade        = ('(''faceted'')'); %       'none', 'flat', 'faceted', 'interp'   
    shade        = ('(''none'')');    %       'none', 'flat', 'faceted', 'interp'
 %  groundstyle  = 'surf';            %       'mesh', 'surf'
    groundstyle  = 'mesh';            %       'mesh', 'surf'

    SK           = [135/255
                    206/255
                    235/255];         % Sky Color  = blue grey

% Chose the EdgeColor depenting groundstyle = 'mesh' versus 'surface'
if groundstyle  == 'mesh'
    EC           = [0 0 0];           % EdgeColor; [0 0 0] = black
else
    EC           = [1 1 0];           % EdgeColor; [1 1 0] = yellow
end

M = scenery4(lept);         % create the scenery matrix
M = M*mountampl; 
%M = zeros(196,196);        % flat test matrix
%M(15:85,15:85) = nan;

[rn,sn]=size(M);
r = 1:rn;
r=r*lept;
r=r-min(r);
r=r-((max(r)-min(r))/2);

s = 1:sn;
s=s*lept;
s=s-min(s);
s=s-((max(s)-min(s))/2);
%max(r)-min(r)
%min(r),max(r)

% Determine our working area
ssize = get(0,'ScreenSize');
viewd = ssize(4)*figurefac/8;

% gereation of the scenery figure  [left    bottom    width   height]
%                                                           viewd-70 for menue bar
%       'NumberTitle','on','Name','scenery','MenuBar','none','NumberTitle',
%       'NumberTitle','on','Name','scenery','MenuBar','figure','NumberTitle','off',... 

figure('Units','pixels','Position',[ 3 ssize(4)-viewd viewd viewd-70],...
       'Name','scenery','MenuBar','figure','NumberTitle','off',...       
       'Color',SK);                                     % Sky color BG + AQM
h1f = gcf;                                              % handle 1 figure
h1a = gca;                                              % handle 1 figure axis
%whitebg(h1f)                                           % night flight
whitebg('white'); set(gcf,'Color',SK)
%whitebg(h1f,[0.15 0.15 .15]) 
%get(h1f)


set(h1f,'renderer','zbuffer')
set(gcf,'DoubleBuffer','on')
set(gco,'EraseMode','xor')
%set(gco,'wireframe','hide')
%get(h1f) 

% gereation of the cockpit figure  [left       bottom            width  height ]
figure('Units','pixels','Position',[ 3 ssize(4)-viewd-viewd/3-25 viewd  viewd/3],...
       'NumberTitle','on','Name','Cockpit','MenuBar','none','NumberTitle','off',...
       'Color',[1 1 1]);
h2f = gcf;                                              % handle 2 figure

h2al= axes('position',[.06 .15 .25 .6],'Visible','on'); % handle 2 figure axes location
h2ah= axes('position',[.36 .15 .25 .6],'Visible','on'); % handle 2 figure axes heading
h2aa= axes('position',[.66 .15 .25 .6],'Visible','on'); % handle 2 figure axes horizon
                                                        % & altitude
% draw the scenery in figure 'scenery'
figure(h1f)
H=eval(strcat(groundstyle,'(r,s,M,''LineWidth'',1,''EdgeColor'',EC)')); hold on
h1o=gco;

axis equal
axisscenery=axis;

% Prepare the color map
colormap([cmapS;cmapP;cmapR;cmapI])
zmin = min(M(:));
zmax = max(M(:));
cdS  = min(C,round((C-1)*(M-zmin)/(zmax-zmin))+1);
cdP  = cdS+C;
cdR  = cdP+C;
cdI  = cdR+C;

% Chose the 'scenery' surface depenting groundstyle = 'mesh' versus 'surface'
if groundstyle ~= 'mesh'
   set(H,'FaceColor',' texturemap')                 % set color map 'scenery'
   set((H),'CData',cdS);
end

% draw a planet in figure 'scenery'
[x,y,z] = sphheli([0 360 -90 +75 5 80 0 7.5 32]);
h(1)=surf(x,y,z,'Tag','planet'); hold on
set(h(1),'FaceColor',' texturemap','CData',cdP)     % set color map 'planet'

% draw a moon in figure 'scenery'
[x,y,z]= sphheli([0 360 -90 +90 2 90 -8 7 16]);
h(2)=surf(x,y,z,'Tag','moon'); hold on
set(h(2),'FaceColor',' texturemap','CData',cdP)     % set color map 'planet'

% draw a radar in figure 'scenery'
[x,y,z] = sphheli([0 360 -90 +90 3 87.8 -85.35 16.85 16]);
h(3)=surf(x,y,z); hold on
set(h(3),'FaceColor',' texturemap','CData',cdR)     % set color map 'Radar'

% draw an igloo in figure 'scenery'
[x,y,z]= sphheli([0 360 0 +90 3 -80 0 0 8]);
h(4)=surf(x,y,z); hold on
set(h(4),'FaceColor',' texturemap','CData',cdI)     % set color map 'igloo'

% Change CLim (Color Limits) so that it spans all the CDatas
caxis([min(cdS(:)) max(cdI(:))])

%camzoom(8); view(-87,4); break                     % Test for look at 'scenery'

% costumize the landscape
set(h1a,'Projection','perspective');                % versus 'orthographic'
axis off                                            %        'perspective'
camzoom(1)
ZLim([-25 45]);
lighting(light)

if shade(3:6) ~= 'none',                            % shading propertie
   eval(strcat('shading',shade))
end
if caml(3:6) ~= 'none',                             % camlight propertie
   eval(strcat('camlight',caml))
end

% Initialize flying controls
offset = get(h1f,'Position');                       % used for center the mouse
center = offset(3:4)./2;                            % dito

set(h1a,'CameraViewAngle', view_angle);             % init Sichtweite
set(0,'PointerLocation',center + offset(1:2))       % center cursor allocation
set(h1f,'Pointer','crosshair')                      % set cursor to crosshair

%x0=55; y0=-88; height_l=18;                        % test for look at radar
%x0=87.8; y0=-110; height_l=16;                     % test for look at radar

cameral = [ x0 y0 height_l];                        % ini Camera allocation
camerat = [ x0+r0 y0 height_t];                     % camera target
%camerat = [ x0 y0+r0 height_t];                    % test for look at radar

% Cockpit preparation
figure(h2f);                                        % make figure 2 cockpit current  

set(h2f,'CurrentAxes',h2al)                         % set cockpit figure and location axis current
location                                            % plot location

set(h2f,'CurrentAxes',h2ah)                         % set cockpit figure and heading axis current
heading                                             % plot heading & speed

set(h2f,'CurrentAxes',h2aa)                         % set cockpit figure and horizon axis current
altitude                                            % plot horizon & altitude

it      = 0;
itt     = 0;
angle_1 = 0;

%  This is the flying loop 
while(1)
    figure(h1f);                                   % make figure 1 scenery current

% camera deviation unit vector
    camerad = (camerat-cameral)./...
              (sqrt(sum((camerat-cameral).^2)));  
    [theta rho]=cart2pol(camerad(1),camerad(2));    % used is only theta

    cameral = cameral+camerad.*velocity;            % camera allocation
    cameral(3)=height_l;

    set(h1a,'CameraPosition',cameral)               % new camera allocation position
    set(h1a,'CameraTarget',camerat)                 % new camera target postion

    drawnow                                         %%%% realy fly now %%%%

    %break; %get(h1f,'CurrentPoint')

% mouse input part    
    stick = get(0,'PointerLocation');
    stick = stick - offset(1:2);

% new height    
    alt   = (center(2)-stick(2))/center(2);         % normalized altitude 0 +1

% give a tolerance for the altitude 0    
    if abs(alt)<alttol
       alt=0;                                       % if altitude < alttol
    end      
    height_l=height_l+alt*altfac;
    if     height_l < heigth_lmin                   % do avoid location height
           height_l = heigth_lmin;                  %                 < heigth_lmin
    elseif height_l > heigth_lmax                   % do avoid location height
           height_l = heigth_lmax;                  %                 > heigth_lmax
    end

% new angle to genrate the heading
    angle = (center(1)-stick(1))/center(1);         % normalized side angle +1-1
    if     angle < -1
           angle = -1;                              % do avoid angle out of figure
    elseif angle > +1
           angle = +1;
    end
    angle=anglefac*angle;                           % multipli the angle by anglefac

% give a tolerance for the angle 0
    if abs(angle)<angletol
       angle=0;                                     % if angle < angletol
       %set(h1a,'CameraUpVectorMode','auto')        % normalize the CameraUpVector
    end

% new heading
    [X,Y] = pol2cart(pi/180*(angle+angle_1),r0);
    angle_1=angle_1+angle;

% new camera target
    X=X+cameral(1);
    Y=Y+cameral(2);
    camerat = [X,Y,height_t];

% CameraUpVector part
    A=sidefac*angle/180*pi;  
    B=-angle_1/180*pi;
    set(gca,'CameraUpVector',[sin(B)*sin(A) cos(B)*sin(A) cos(A)])
             
 % keybourd input
    switch(lower(get(h1f,'CurrentCharacter')));
        case 'q', velocity=velocity+.1; set(h1f,'CurrentCharacter','1')
        case 'a', velocity=velocity-.1; set(h1f,'CurrentCharacter','1')
        case 's', height_t=height_t-4; set(h1f,'CurrentCharacter','1')
        case 'w', height_t=height_t+4; set(h1f,'CurrentCharacter','1')
        case 'y', set(0,'PointerLocation',center + offset(1:2))
                  set(h1f,'CurrentCharacter','1')
        case 'n', whitebg(h1f,[0.15 0.15 .15])          % night flight
        case 't', whitebg(h1f,[200/255 0 0])            % twilight flight
        case 'd', whitebg([1 1 1]); set(h1f,'Color',SK) % day flight
        case 'x', break;
    end

    if     velocity < velocity_min                  % do avoid velocity
           velocity = velocity_min;                 %        < veloc_min
    elseif velocity > velocity_max                  % do avoid velocity
           velocity = velocity_max;                 %        > veloc_max
    end

    if     height_t <= heigth_tmin                  % do avoid height_t
           height_t  = heigth_tmin;                 %        < heigth_tmin
    elseif height_t >= heigth_tmax                  % do avoid height_target
           height_t  = heigth_tmax;                 %        > heigth_lmax
    end 

% Cockpit processing
    figure(h2f);                            % make figure 2 cockpit current
%   set(h1o,'wireframe','mesh')
    delete(findobj('FontWeight','demi'))    % delete all numeric text t-1 
    delete(findobj('MarkerSize',5))         % delete the locationMarker headingMarker t-1
    delete(findobj('LineWidth',2))          % delete the horizonBeam t-1  

% LOCATION: plot the history dots and the current location as marker
    set(h2f,'CurrentAxes',h2al)             % set cockpit figure and location axis current
    cmx=cameral(1)/(axisscenery(2)-axisscenery(1))*2;
    cmy=cameral(2)/(axisscenery(3)-axisscenery(4))*2;
    it=it+1;
    if mod(it,25)==0 %25
       it=0; itt=itt+1;
       if itt > 6; itt=1; end
       plot(cmx,cmy,'db','MarkerFaceColor','b','MarkerSize',2.5,'Tag',sprintf('%0.0f',itt)); hold on
       if itt==6; delete(findobj('Tag','1')),end
       if itt==5; delete(findobj('Tag','6')),end
       if itt==4; delete(findobj('Tag','5')),end
       if itt==3; delete(findobj('Tag','4')),end
       if itt==2; delete(findobj('Tag','3')),end
       if itt==1; delete(findobj('Tag','2')),end
    end
    plot(cmx,cmy,'db','MarkerFaceColor','b','MarkerSize',5); hold on

% HEADING: plot the current heading as marker
    set(h2f,'CurrentAxes',h2ah)             % set cockpit figure and heading axis current
    plot(cos(-theta),sin(-theta),...
    'sb','MarkerFaceColor','b','MarkerSize',5); hold on

% print the current heading numeric
    text(0,0,sprintf('%0.1f',-theta/pi*180),...
    'horizontalalignment','center','color','b',...
    'FontSize',9,'FontWeight','demi')

% print the current speed numeric
    text(-.6,0,sprintf('%0.1f',velocity),...
    'horizontalalignment','center','color','b',...
    'FontSize',9,'FontWeight','demi')

% HORIZON:  plot the current horizon as beam
    set(h2f,'CurrentAxes',h2aa)             % set cockpit figure and horizon axis current
    plot([sin(-A*2),-sin(-A*2)],...
         [cos(-A*2),-cos(-A*2)],...
         '-','LineWidth',2); hold on
     
% print the current altitude numeric
    text(-.6,0,sprintf('%0.2f',height_l),...
    'horizontalalignment','center','color','b',...
    'FontSize',9,'FontWeight','demi')
end
return

%  Begin of the subfunction part 

function [M] = scenery4(lept);
%function [M] = scenery(lept)
%SCENERY Generate the scenery

    dx = 1/8*lept;
    [x,y] = meshgrid(-3:dx:3);

 Z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2) ...
   - 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2) ...
   - 1/3*exp(-(x+1).^2 - y.^2);

    [m,n]=size(Z);

    Z(:,floor(10/lept):(floor(10/lept)+floor(10/lept)))=...
    Z(:,(floor(20/lept):floor(20/lept)+floor(10/lept)));  % cut the landscape and
    Z=Z';                                                 % rebuild

%mesh(Z);set(gcf,'renderer','zbuffer')    
    
M=zeros(4*m, 4*n);
%size(M)
    M(0*m+1:1*m, 0*n+1:1*n) = Z;
    M(0*m+1:1*m, 1*n+1:2*n) = Z;
    M(0*m+1:1*m, 2*n+1:3*n) = Z;
    M(0*m+1:1*m, 3*n+1:4*n) = Z;

    M(1*m+1:2*m, 0*n+1:1*n) = Z;
    M(1*m+1:2*m, 1*n+1:2*n) = Z;
    M(1*m+1:2*m, 2*n+1:3*n) = Z;
    M(1*m+1:2*m, 3*n+1:4*n) = Z;

    M(2*m+1:3*m, 0*n+1:1*n) = Z;
    M(2*m+1:3*m, 1*n+1:2*n) = Z;
    M(2*m+1:3*m, 2*n+1:3*n) = Z;
    M(2*m+1:3*m, 3*n+1:4*n) = Z;

    M(3*m+1:4*m, 0*n+1:1*n) = Z;
    M(3*m+1:4*m, 1*n+1:2*n) = Z;
    M(3*m+1:4*m, 2*n+1:3*n) = Z;
    M(3*m+1:4*m, 3*n+1:4*n) = Z;

%mesh(M);set(gcf,'renderer','zbuffer') 
return

function [Xn,Yn,Zn] = sphheli(sphm)
% Modification Log:
%   created: 25. oct 2003 by A. Plattner
%   last revision: dd mmm yyyy
%
% Function:
%   This function produces a sphere segment
%
% Syntax:
%           azb   aze     elb     ele     rn      xn      yn      zn      steps    
%   sph([    0    240     +70     -90     1       0       0       0       64]);
%
%   [x,y,z] = sphheli([azb  aze  elb  ele  rn  xn  yn  zn  steps])
%   generates three (steps+1)-by-(steps+1)
%   matrices so that surf(x,y,z) produces a unit sphere-segment
%
% Inputs:
%   azb           begin azimut            0 : 360
%   aze           end azimut              0 : 360
%   elb           begin Elevation       +90 : -90
%   ele           end Elevation         +90 : -90
%   rn            range
%   xn            Shift x axis
%   yn            Shift y axis
%   zn            Shift z axis
%   steps         steps
%
%Example 
%   [x,y,z]= sphheli([0 270 -90 +75 1 0 0 0 24]);
%            surf(x,y,z);
%            set(gcf,'renderer','zbuffer')  % if necessary

if nargin == 0
%             azb   aze     elb     ele     rn      xn      yn      zn      steps    
   sphm    = [ 0    360     +90     -90     1       0       0       0       20];
end

%[m,n] = size(sphm);
                                % Felddefinitionen
    azb   = 01;                 % begin azimut            0 : 360
    aze   = 02;                 % end azimut              0 : 360
    elb   = 03;                 % begin Elevation       +90 : -90
    ele   = 04;                 % end Elevation         +90 : -90
    rn    = 05;                 % range
    xn    = 06;                 % Shift x
    yn    = 07;                 % Shift y
    zn    = 08;                 % Shift z
    steps = 09;                 % Steps
    azbr  = 10;                 % begin azimut      in RAD
    azer  = 11;                 % end azimut        in RAD
    elbr  = 12;                 % begin Elevation   in RAD
    eler  = 13;                 % end Elevation     in RAD

% degrees to Rad
    sphm(azbr)=sphm(azb)/180*pi;
    sphm(azer)=sphm(aze)/180*pi;
    sphm(elbr)=(90-sphm(elb))/180*pi;
    sphm(eler)=(90-sphm(ele))/180*pi;
    sphm(steps)=sphm(steps)+1;

% Sphere segments
    phi=linspace(sphm(azbr),sphm(azer),sphm(steps));    % Azimut
    theta=linspace(sphm(elbr),sphm(eler),sphm(steps));  % Elevation
    theta=theta';
    Xn=sphm(xn)+sphm(rn)*sin(theta)*cos(phi);           % X-Points
    Yn=sphm(yn)+sphm(rn)*sin(theta)*sin(phi);           % Y-Points
    Zn=sphm(zn)+sphm(rn)*cos(theta)*ones(size(phi));    % Z-Points

    if nargout == 0
        % disp('hello')
        surf(Xn,Yn,Zn)          % same as surface(Xn,Yn,Zn)
    else
        XX = Xn; YY = Yn; ZZ = Zn;
    end
return

function [] = location
%LOCATION  location plot.
%   LOCATION(axisscenery,cameral) makes a plot of the border
%   and plots the actual location

%   Copyright (c) 06. may 2002 by Andreas Plattner
%   Revision: 1.0

    hold on

% figure setings
    axis off
    set(gca,'dataaspectratio',[1 1 1])
    view(90,-90)

% draw the border of the scenery and the 0/0 Cross in green
    plot([-1 -1 1 1 -1],[-1 1 1 -1 -1],'-','color',[0 0 0],'linewidth',1);
    plot([-.5 .5],[0 0],'-','color',[0 1 0],'linewidth',1);
    plot([0 0],[-.5 .5],'-','color',[0 1 0],'linewidth',1);
        
% annotate Title
    text(1.35,0,' location',...
    'horizontalalignment','center','color','b',...
    'FontWeight','light')

% annotate North Marker 'N' and the planet
    text(.4,0,'N',...                               % North Marker
    'horizontalalignment','center','color','r',...
    'FontWeight','bold')
    patch(.8,0,0,'LineWidth',8','EdgeColor','g')    % Planet
    plot(.9,.1,'.r','LineWidth',1')                 % Moon
    patch(.88,.85,0,'LineWidth',3','EdgeColor','b') % Radar
    plot(-.8,0,'ok','LineWidth',1)                  % Igloo
return

function [] = heading
%HEADING  heading plot.
%   HEADING(THETA) makes a plot using polar coordinates of
%   the angle THETA, in radians, versus the radius 1

%   Copyright (c) 06. may 2002 by Andreas Plattner
%   Revision: 1.0

    hold on    

% figure setings
    axis off
    set(gca,'dataaspectratio',[1 1 1])
    view(90,-90)

% define a circle
    th    = 0:pi/50:2*pi;
    xunit = cos(th);
    yunit = sin(th);

% draw the radial circle
    plot(xunit,yunit,'-','color',[0 0 0],'linewidth',1);
 
% plot background yellow
    patch('xdata',xunit,'ydata',yunit,'facecolor',[1 1 0])
         
% plot marker
    th    = 0:pi/6:2*pi;
    xunit = cos(th);
    yunit = sin(th);
    plot(xunit,yunit,'s','LineWidth',1,'MarkerEdgeColor',...
    'b','MarkerFaceColor','b','MarkerSize',2);    

% annotate Title 'heading'
    text(1.35,0,' heading',...
    'horizontalalignment','center','color','b',...
    'FontWeight','light')    

% annotate Title 'speed'
    text(-1.35,0,'speed',...
    'horizontalalignment','center','color','b',...
    'FontWeight','light')    

% annotate North Marker 'N' and 'uparrow'
    text(.4,0,'N',...                               % North Marker
    'horizontalalignment','center','color','r',...
    'FontWeight','bold')
    text(.72,0,'\uparrow',...                       % uparrow
    'horizontalalignment','center','color','r',...
    'FontWeight','demi')
return

function [] = altitude
%ALTITUDE  horizon and altitude plot.
%   ALTITUDE(camroll,height) makes a plot using polar coordinates of
%   the angle camroll in degrees and plot the altitude

%   Copyright (c) 06. may 2002 by Andreas Plattner
%   Revision: 0.1

    hold on

% figure setings
    axis off
    set(gca,'dataaspectratio',[1 1 1])
    view(90,-90)

% define a circle
    th    = 0:pi/50:2*pi;
    xunit = cos(th);
    yunit = sin(th);
      
% draw the radial circle
    plot(xunit,yunit,'-','color',[0 0 0],'linewidth',1);

% annotate Title 'horizon deg. x 2' see Lines 565,566
    text(1.35,0,' horizon deg. x 2',...
    'horizontalalignment','center','color','b',...
    'FontWeight','light')    

% annotate Title 'altitude'
    text(-1.35,0,'altitude',...
    'horizontalalignment','center','color','b',...
    'FontWeight','light')    
return

Contact us at files@mathworks.com