'''
Computations for Hammer and Feather
'''
import math
fAccelerationEarth = 9.8 # m/s^2
fMassMoon = 7.3476E22 # kg
fRadiusMoon = 1737400 # meters average radius of the moon
G = 6.6743015E-11 # CODATA 2014
fAccelerationMoon = G * fMassMoon / (fRadiusMoon*fRadiusMoon) # m/s^2
# Drop time calculations
# Kinematic equation used:
# x = v0 * t + 1/2 * a* t^2
# x is height
# v0 is velocity at time zero = 0, the term goes to zero
# x = 1/2 * a * t^2
# solve for t
# 2 * x / a = t^2
# sqrt(2 * x / a) = t
# http://hyperphysics.phy-astr.gsu.edu/hbase/mot.html
fHeightDrop = 1.2 # meters
fDropTimeMoon = math.sqrt(2 * fHeightDrop / fAccelerationMoon)
fDropTimeEarth = math.sqrt(2 * fHeightDrop / fAccelerationEarth)
# Frame count analysis
# numFrames = dropTime * frameRate
# Dimensional analysis: frames = s * frames/s, seconds cancel giving frames = frames
fFrameRate = 29.97 # frames per second
fFramesMoon = fDropTimeMoon * fFrameRate
fFramesEarth = fDropTimeEarth * fFrameRate
# Video speed ratio analysis
# frEarth/framesEarth = frMoon/framesMoon
# frEarth = ( frMoon/framesMoon ) * framesEarth
fFrameRateEarth = ( fFrameRate / fFramesMoon ) * fFramesEarth
fFrameRateRatio = fFrameRate / fFrameRateEarth
print ("Gravity: ")
print ("Universal Gravitational constant: {} m^3 / kg * s^2".format(G))
print ("Mass of the moon: {} kg".format(fMassMoon))
print ("Radius of the moon {} meters".format(fRadiusMoon))
print ("Gravitational acceleration {} m / s^2".format(fAccelerationMoon))
print ()
print ("Time to drop: ")
print ("Height of drop: {} meters".format(fHeightDrop))
print ("Time of drop moon: {} seconds".format(fDropTimeMoon))
print ("Time of drop earth: {} seconds".format(fDropTimeEarth))
print ()
print ("Predicted frame count: ")
print ("Frames per second: {} frames per second".format(fFrameRate))
print ("Frame count moon: {} frames".format(fFramesMoon))
print ("Frame count earth: {} frames".format(fFramesEarth))
print ()
print ("Frame rate ratio: ")
print ("Necessary frame rate of original footage: {} frames per second".format(fFrameRateEarth))
print ("Frame rate speedup: {} ".format(fFrameRateRatio))