from units import *
from orbit import *
from math import *

radian = 1.0
degree = pi / 180
twopi = 2 * pi

armLength = 800 * mile
omega = circularOmegaFromRadius(earthRadius + armLength)
cogSpeed = circularVelocityFromRadius(earthRadius + armLength)
groundSpeed = omega * earthRadius
spinRate = groundSpeed / armLength
spinPeriod = twopi / spinRate

print armLength.inTermsOf(mile), "length of pinwheel arms"

print groundSpeed.inTermsOf(MPH), "ground speed of pinwheel"

# assume a max acceptable vertical range, then back-compute the
# capture time

verticalPlay = 100 * foot
sliver = 2 * acos(1 - verticalPlay / armLength)
window = sliver / spinRate

print window.inTermsOf(second), "to grab the cable"

print (pi / spinRate).inTermsOf(minute), "riding the pinwheel"

print (2 * cogSpeed).inTermsOf(MPS), "speed when leaving the pinwheel"

earthCircumference = twopi * earthRadius
hop = groundSpeed * spinPeriod
#print hop.inTermsOf(mile), "hop"
n = int(earthCircumference / hop + 0.5)
print n, "pinwheel rotations til next try"
print (n * spinPeriod).inTermsOf(minute), "til next try"
print abs(n * hop - earthCircumference).inTermsOf(mile), "to next try"

#o = Orbit(earthRadius + 2 * armLength, 2 * cogSpeed)
#print o.perigee
#print o.apogee
