PRO PROP_NET
device,decomposed=0

r_earth = 1.495*10.0^(11.0)
r_mars = 2.279*10.0^(11.0)


total_d_ind = dblarr(10)
FOR n_layer=1,3 DO BEGIN

;n_layer = 9.0
n_sat = 32.0

;routing
deg_earth = 0.0
deg_mars = 180.0

diff = ABS(deg_earth - deg_mars)
IF diff GE 180.0 THEN diff = 360.0 - diff
roundsats = FLOOR(diff/(360.0/n_sat))
print,roundsats

r_sat = dblarr(n_layer)
FOR i=0,n_layer-1 DO BEGIN
r_sat[i] = (r_mars - ((i+1.0)*((r_mars - r_earth)/(n_layer+1.0))))
ENDFOR

angle = 360.0/n_sat

; earth dist
r_sat_prior = r_mars
total_d = 0.0
FOR i=0,n_layer-1 DO BEGIN

h_c = r_sat[i]*(1.0-cos((!DTOR*angle)/2.0))
c = 2.0*r_sat[i]*sin((!DTOR*angle)/2.0)
d = SQRT(((r_sat_prior - r_sat[i]) + h_c)^2.0 + (c/2.0)^2.0)

print,i,d

total_d = total_d + d
r_sat_prior = r_sat[i]
ENDFOR

h_c = r_sat_prior*(1.0-cos((!DTOR*angle)/2.0))
c = 2.0*r_sat_prior*sin((!DTOR*angle)/2.0)
d = SQRT(((r_sat_prior - r_earth) + h_c)^2.0 + (c/2.0)^2.0)

print,'Earth stage',d

total_d = total_d + d

d_lateral = roundsats*((2.0 * r_sat[n_layer-1])*sin((!DTOR*angle)/2.0))

print,'lateral',d_lateral

total_d = total_d + d_lateral

print,'total:',total_d

total_d_ind[n_layer-1.0] = total_d

ENDFOR

plot,total_d_ind

END