% Figure to illustrate different retinal coordinate systems.

clear all
close all

fs=14; % fontsize to use for axis labels
fsa=18; % fontsize to use for panel labels
fst = 18; % fontsize to use for titles

% Head-centered coordinates of viewed object
objectP = [-6 7 10];

% Coordinates of real eye:
interoculardistance = 6;
eyes.radius = 1.75;
eyes.eyeballcolor = [0.75 0.75 0.5];
eyes.eyeballtransparency = 0.8;
% Specify eye positions
eyes.eyepos.nodal = [0; 0 ; 0];
eyes.eyepos.azimuth = 0;
eyes.eyepos.elevation = 0;
eyes.eyepos.torsion = 0;
% Colors in which to draw coordinate systems
eyes.azcoordcol = 'k' ;
eyes.elcoordcol = 'k' ;

% Specify the coordinate system to be painted on the retina
coordsystem.nlines = 13;
spacing = 15;
coordsystem.sca  = 1.01; % amount by which to exaggerate eyeball radius so coord lines are visible
coordsystem.linewidth = 0.5;
coordsystem.linewidththick = 1.5; % used for plotting meridians
coords = {'CartesianVirtualPlane' 'azlongellong' 'azlongellat' 'azlatellong' 'azlatellat'};
names = {'(x,y)' '(\alpha, \eta)' '(\alpha, \kappa)' '(\beta, \eta)' '(\beta, \kappa)' };
figure('pos',[   5         329        1160         292])
% Draw the eyes
DrawEyes(eyes);
for jcoord=1:length(coords)    
    if jcoord==1
        coordsystem.spacing = eyes.radius * tand(spacing);
        coordsystem.retcol = [0.3 0.3 0.3];
    else
        coordsystem.spacing = spacing;
    end
    subplot(1,length(coords),jcoord)
    % Mark on coordinate system:
    coordsystem.name = coords{jcoord};
    DrawEyes(eyes);
    eyecoordhandles = DrawEyeCoords(eyes,coordsystem);

    camup([0 1 0])
    camtarget([ 0 0 0])
    campos([-7 7 -25])
    camva(7)
    lighting phong
    camlight headlight
    camlight right
    axis equal tight off
    xlim([-1 1]*3.5)
    ylim([-1 1]*3.5)
    zlim([-1 1]*3.5)
    set(gcf,'color','w')
    text(0,1.8*eyes.radius,-eyes.radius,names{jcoord},'fonts',14)
    text(eyes.radius,1.8*eyes.radius,-eyes.radius,char(64+jcoord),'fonts',18,'fontw','bold')
    
end
print -dtiff -r800 -zbuffer Fig_DiffRetCoords
