k=1000;
c=299860*k;

global sat_pos
global PR
global Atlanta_coords
global transformation_inverse
global transformation_matrix
% Making this global will speed up things. We wont do parameter passing

earth_radius=6380*k;
gps_altitude=20200*k;
gps_radius=earth_radius+gps_altitude;


Atlanta_altitude=304.8;
Atlanta_radius=Atlanta_altitude+earth_radius;
Atlanta_latitude=33.65;
Atlanta_longitude=-84.42;

Atlanta_coords(1)=Atlanta_radius*cos(Atlanta_latitude*pi/180)*cos(Atlanta_longitude*pi/180);
Atlanta_coords(2)=Atlanta_radius*cos(Atlanta_latitude*pi/180)*sin(Atlanta_longitude*pi/180);
Atlanta_coords(3)=Atlanta_radius*sin(Atlanta_latitude*pi/180);

sat_longitudes=[-62.3256, -85.2234, -92.8388];
sat_latitudes=[7.8520, 45.1053, 29.7834];
sat_PR_times=[0, -0.003817986, -0.004077077];

sat_longitudes=sat_longitudes*pi/180;
sat_latitudes=sat_latitudes*pi/180;

for i=1:3
    [sat_pos(1,i), sat_pos(2,i), sat_pos(3,i)]=sph2cart(sat_latitudes(i), sat_longitudes(i),  gps_radius);
    PR(i)=sat_PR_times(i)*c;
end

transform_z=Atlanta_coords/norm(Atlanta_coords);
transform_y=[-sin(Atlanta_longitude*pi/180) cos(Atlanta_longitude*pi/180) 0];
transform_x=cross(transform_y, transform_z);

transformation_matrix=[transform_x; transform_y; transform_z];
transformation_inverse=inv(transformation_matrix);