% [geo] = gei2geo(gei) transform gei coordinates into geo (xyz)
%
% Initial version: Magnus Billvik, Swedish Institute of Space Physics,
%Uppsala, June 2005
% Revised by: Niklas Edberg, Swedish Institute of Space Physics, Uppsala,

function [geo] = gei2geo(gei,jd)

geo=ones(size(gei));    % declare the variabel before to speed up the loop!

mjd=jd-2400000.5;                          % modified julian days
theta=100.461+36000.77*(floor(mjd)-51544.5)/36525+15.04107*(mjd-floor(mjd))*24;    % greenwich mean siderial time (days). From Hopgood.

for i=1:length(gei)
    T=R(theta(i)*pi/180);
    geo(:,i)=T*gei(:,i);  % rosettas coord
end
