// This program plots the orbits of the planets, to scale.
// (It naievely assumes circular orbits)
// It demonstrates how a very large range of numbers can be
//  plotted on the same graph.
// The inner planets appear very close together, but you can
//  zoom in to view them -- press enter repeatedly to zoom in.
// Press "Kill Program" to exit.

//   Planet   Dist from sun   Mass          Time for 1 orbit
//            million km      x 10^22 kg    days
//   --------  --------    ----------      ---------  
Data Mercury,    58,            33.0,           88.0         
Data Venus,      108,          487,            224.7        
Data Earth,      150,          598,            365.2
Data Mars,       228,           64.2,          687.0         
Data Jupiter,    778,       190000,           4332          
Data Saturn,    1429,        56900,          10760 
Data Uranus,    2871,         8690,          30700         
Data Neptune,   4504,        10280,          60200         
Data Pluto,     5913,            1.49,       90600

dim planet$ (9), distance (9), mass (9),orbit_days (9)
for i = 0 to 8
  read planet$ (i), distance (i), mass (i), orbit_days (i)
  distance (i) = distance (i) * 1000000  // in km
  print planet$ (i), distance (i)
next
degrees
scale = distance(8) * 2 / 7
offset = distance(8) * 7.5 / 7
graph height=7.5, width = 7.5, hscale=scale, vscale=scale
graph voffset=offset, hoffset = offset

// draw the orbits.
for i = 0 to 8
  r = distance(i)
  plot color=(0,200,200),unsorted
  rc = fndraw_circle (0,0,r,r)
  name_dist = distance(i)*.707
  text size=12,string=planet$(i), x=-name_dist, y=-name_dist
next

mkm$ = "Kilometers"
text xaxis h=75,string=mkm$
sun$="Sun"
text x=0,y=0,color=(255,0,0),string=sun$,size=15

250
print "press enter to zoom in"
line input xx$
if scale > 2e7 then goto 260
scale = distance(8) * 2 / 7	// reset scale to Pluto
offset = distance(8) * 7.5 / 7
goto 270
260
scale = scale / 1.5		// zoom in				
offset = offset / 1.5		
270
graph hscale=scale,vscale=scale,hoffset=offset,voffset=offset
goto 250


//--------------------------------------
def fndraw_circle (h, v, rh, rv) = gosub 10000
10000
//plot red=r,green=g,blue=b,unsorted
for ang=0 to 360 step 5
  plot x=h+rh*cos(ang), y=v+rv*sin(ang)
next
return
// ------------------------------------
         