function drawrosetta(proben, relradius)

% DRAWROSETTA(probenumber, relradius, sp_angle) draws a long/lat plot over the spacecraft as seen from 
% probe 'probenumber'. The size of the high-gain antenna is given by 'relradius' which is the radius relative to the actual radius.
%
% Resolution: 400 pixels/inch = 2400x1800 pixels
%
% (box) model of the s/c (1) and the solar panels (2 and 3), built up of 12 lines in total (unit: millimeters)
% "s" are the x,y,z start values (in millimeters)
% m1x, m1y and m1z are coordinates along the lines, resolution: 25, 25 and 45 mm respectively
%
% Initial version: Magnus Billvik, Swedish Institute of Space Physics,
% Uppsala, June 2005

switch proben
case 1
    sp_angle=60*(pi/180); % the solar panel rotation angle around the y axis (radians)
case 2
    sp_angle=-45*(pi/180);
end   

% the s/c body
m1x=[-1125:75:1125];
m1y=[-1000:80:1000];
m1z=[0:95:2660];

% solar panel 1
m2x=[-1125:150:1125]*sin(sp_angle);
m2y=[2100:400:14100];
m2z=1325+[-1125:150:1125]*cos(sp_angle);

% solar panel 2
m3x=m2x;
m3y=[-2100:-400:-14100];
m3z=m2z;

% high gain antenna
m4c=[1125 0 -1100];                    % center of high gain antenna
m4r=1050*relradius;                    % radius of high gain antenna
m4y=m4c(2)+m4r*sin((1:10:370)*pi/180); % high gain antenna (a disc in the yz plane)
m4z=m4c(3)+m4r*cos((1:10:370)*pi/180);
m4x=m4c(1)*ones(1,length(m4y));

% coordinates for the LAP probes' tips
p1x=-1190;
p1y=2430;
p1z=3880;
p2x=-2480;
p2y=780;
p2z=-1557;

% As an alternative to the LAP coords above:
% coordinates for the MAG sensors (1=IB, 2=OB)
%p1x=-2131;
%p1y=734;
%p1z=-344;
%p2x=-2250;
%p2y=746;
%p2z=-434;


% coords for the LAP boom holds
p1sx=-1190;
p1sy=850;
p1sz=2300;
p2sx=-1190;
p2sy=650;
p2sz=300;

% As an alternative to the LAP coords above:
% coordinates for the MAG boom holds (same as LAP2 holds)
%p1sx=-1190;
%p1sy=650;
%p1sz=300;
%p2sx=-1190;
%p2sy=650;
%p2sz=300;



center=[mean([m1x(1) m1x(length(m1x))]) mean([m1y(1) m1y(length(m1y))]) mean([m1z(1) m1z(length(m1z))])]; % the centrum point for the model (for drawing polygons!)
center1=[0 mean([m2y(1) m2y(length(m2y))]) mean([m2z(1) m2z(length(m2z))]) ]; % the centrum point for the solar panel 1 model (for drawing polygons!)
center2=[0 mean([m3y(1) m3y(length(m3y))]) mean([m3z(1) m3z(length(m3z))]) ]; % the centrum point for the solar panel 2 model (for drawing polygons!)

% translation so that origo is at the chosen probe
% and make a model for the other (visible) probe
switch proben

case 1,
    m1x=m1x-p1x;
    m1y=m1y-p1y;
    m1z=m1z-p1z;
    m2x=m2x-p1x; 
    m2y=m2y-p1y;
    m2z=m2z-p1z;
    m3x=m3x-p1x;
    m3y=m3y-p1y;
    m3z=m3z-p1z;
    m4x=m4x-p1x;
    m4y=m4y-p1y;
    m4z=m4z-p1z;
    m4c=m4c-[p1x p1y p1z];
    vprobex=p2sx+(p2x-p2sx)/10*[0:10]-p1x;   % model for probe 2
    vprobey=p2sy+(p2y-p2sy)/10*[0:10]-p1y;
    vprobez=p2sz+(p2z-p2sz)/10*[0:10]-p1z;
    center=center-[p1x p1y p1z];
    center1=center1-[p1x p1y p1z];
    center2=center2-[p1x p1y p1z];

case 2,
    m1x=m1x-p2x;
    m1y=m1y-p2y;
    m1z=m1z-p2z;
    m2x=m2x-p2x; 
    m2y=m2y-p2y;
    m2z=m2z-p2z;
    m3x=m3x-p2x;
    m3y=m3y-p2y;
    m3z=m3z-p2z;
    m4x=m4x-p2x;
    m4y=m4y-p2y;
    m4z=m4z-p2z;
    m4c=m4c-[p2x p2y p2z];
    vprobex=p1sx+(p1x-p1sx)/10*[0:10]-p2x;  % model for probe 1
    vprobey=p1sy+(p1y-p1sy)/10*[0:10]-p2y;
    vprobez=p1sz+(p1z-p1sz)/10*[0:10]-p2z;
    center=center-[p2x p2y p2z];
    center1=center1-[p2x p2y p2z];
    center2=center2-[p2x p2y p2z];
    
end

% define start and end values

m1sx=m1x(1);
m1sy=m1y(1);
m1sz=m1z(1);
m1ex=m1x(length(m1x));
m1ey=m1y(length(m1y));
m1ez=m1z(length(m1z));

m2sx=m2x(1);
m2sy=m2y(1);
m2sz=m2z(1);
m2ex=m2x(length(m2x));
m2ey=m2y(length(m2y));
m2ez=m2z(length(m2z));

m3sx=m3x(1);
m3sy=m3y(1);
m3sz=m3z(1);
m3ex=m3x(length(m3x));
m3ey=m3y(length(m3y));
m3ez=m3z(length(m3z));


% plot the spacecraft model as seen from the probe

% filled polygons
% x-lines
drawmodellonglatf(m1x, m1sy*ones(1,length(m1x)), m1sz*ones(1,length(m1x)),'color', [1 0 0], center);
drawmodellonglatf(m1x, m1sy*ones(1,length(m1x)), m1ez*ones(1,length(m1x)),'color', [0 0 0], center);
drawmodellonglatf(m1x, m1ey*ones(1,length(m1x)), m1sz*ones(1,length(m1x)),'color', [0 0 0], center);
drawmodellonglatf(m1x, m1ey*ones(1,length(m1x)), m1ez*ones(1,length(m1x)),'color', [0 0 0], center);
% y-lines
drawmodellonglatf(m1sx*ones(1,length(m1y)), m1y, m1sz*ones(1,length(m1y)),'color', [0 1 0], center);
drawmodellonglatf(m1sx*ones(1,length(m1y)), m1y, m1ez*ones(1,length(m1y)),'color', [0 0 0], center);
drawmodellonglatf(m1ex*ones(1,length(m1y)), m1y, m1sz*ones(1,length(m1y)),'color', [0 0 0], center);
drawmodellonglatf(m1ex*ones(1,length(m1y)), m1y, m1ez*ones(1,length(m1y)),'color', [0 0 0], center);
% z-lines
drawmodellonglatf(m1sx*ones(1,length(m1z)), m1sy*ones(1,length(m1z)), m1z,'color', [0 0 1], center);
drawmodellonglatf(m1sx*ones(1,length(m1z)), m1ey*ones(1,length(m1z)), m1z,'color', [0 0 0], center);
drawmodellonglatf(m1ex*ones(1,length(m1z)), m1sy*ones(1,length(m1z)), m1z,'color', [0 0 0], center);
drawmodellonglatf(m1ex*ones(1,length(m1z)), m1ey*ones(1,length(m1z)), m1z,'color', [0 0 0], center);
% solar panel 1
drawmodellonglatf(m2sx*ones(1,length(m2y)), m2y, m2sz*ones(1,length(m2y)), 'color', [0 0 0], center1);
drawmodellonglatf(m2ex*ones(1,length(m2y)), m2y, m2ez*ones(1,length(m2y)), 'color', [0 0 0], center1);
drawmodellonglatf(m2x, m2sy*ones(1,length(m2z)), m2z, 'color', [0 0 0], center1);
drawmodellonglatf(m2x, m2ey*ones(1,length(m2z)), m2z, 'color', [0 0 0], center1);
% solar panel 2
drawmodellonglatf(m3sx*ones(1,length(m3y)), m3y, m3sz*ones(1,length(m3y)), 'color', [0 0 0], center2);
drawmodellonglatf(m3ex*ones(1,length(m3y)), m3y, m3ez*ones(1,length(m3y)), 'color', [0 0 0], center2);
drawmodellonglatf(m3x, m3sy*ones(1,length(m3z)), m3z, 'color', [0 0 0], center2);
drawmodellonglatf(m3x, m3ey*ones(1,length(m3z)), m3z, 'color', [0 0 0], center2);
% high gain antenna
if relradius>0
	drawmodellonglatf(m4x, m4y, m4z, 'color', [0 0 0], m4c);
end


% lines
% x-lines
drawmodellonglat(m1x, m1sy*ones(1,length(m1x)), m1sz*ones(1,length(m1x)),'color', [1 0 0]);
drawmodellonglat(m1x, m1sy*ones(1,length(m1x)), m1ez*ones(1,length(m1x)),'color', [0 0 0]);
drawmodellonglat(m1x, m1ey*ones(1,length(m1x)), m1sz*ones(1,length(m1x)),'color', [0 0 0]);
drawmodellonglat(m1x, m1ey*ones(1,length(m1x)), m1ez*ones(1,length(m1x)),'color', [0 0 0]);
% y-lines
drawmodellonglat(m1sx*ones(1,length(m1y)), m1y, m1sz*ones(1,length(m1y)),'color', [0 1 0]);
drawmodellonglat(m1sx*ones(1,length(m1y)), m1y, m1ez*ones(1,length(m1y)),'color', [0 0 0]);
drawmodellonglat(m1ex*ones(1,length(m1y)), m1y, m1sz*ones(1,length(m1y)),'color', [0 0 0]);
drawmodellonglat(m1ex*ones(1,length(m1y)), m1y, m1ez*ones(1,length(m1y)),'color', [0 0 0]);
% z-lines
drawmodellonglat(m1sx*ones(1,length(m1z)), m1sy*ones(1,length(m1z)), m1z,'color', [0 0 1]);
drawmodellonglat(m1sx*ones(1,length(m1z)), m1ey*ones(1,length(m1z)), m1z,'color', [0 0 0]);
drawmodellonglat(m1ex*ones(1,length(m1z)), m1sy*ones(1,length(m1z)), m1z,'color', [0 0 0]);
drawmodellonglat(m1ex*ones(1,length(m1z)), m1ey*ones(1,length(m1z)), m1z,'color', [0 0 0]);
% solar panel 1
drawmodellonglat(m2sx*ones(1,length(m2y)), m2y, m2sz*ones(1,length(m2y)), 'color', [0 0 0]);
drawmodellonglat(m2ex*ones(1,length(m2y)), m2y, m2ez*ones(1,length(m2y)), 'color', [0 0 0]);
drawmodellonglat(m2x, m2sy*ones(1,length(m2z)), m2z, 'color', [0 0 0]);
drawmodellonglat(m2x, m2ey*ones(1,length(m2z)), m2z, 'color', [0 0 0]);
% solar panel 2
drawmodellonglat(m3sx*ones(1,length(m3y)), m3y, m3sz*ones(1,length(m3y)), 'color', [0 0 0]);
drawmodellonglat(m3ex*ones(1,length(m3y)), m3y, m3ez*ones(1,length(m3y)), 'color', [0 0 0]);
drawmodellonglat(m3x, m3sy*ones(1,length(m3z)), m3z, 'color', [0 0 0]);
drawmodellonglat(m3x, m3ey*ones(1,length(m3z)), m3z, 'color', [0 0 0]);
% the high gain antenna
if relradius>0
	drawmodellonglat(m4x, m4y, m4z, 'color', [0 0 0]);
end

% the other probe
drawmodellonglat(vprobex, vprobey, vprobez, 'color', [0 0 0]);
[p2phi, p2theta, p2rho]=cart2sphere(vprobex(length(vprobex)),vprobey(length(vprobex)),vprobez(length(vprobex)));
p2phi=p2phi*180/pi;
p2theta=p2theta*180/pi;
plot(p2phi, p2theta, 'ko');

