import numpy as np
import matplotlib.pyplot as plt
#Use this cell to calculate the velocity of a ball after falling 2 meters
initialHeight = 2 # meters
gravityAccMag = 9.81 #meters/s^2, magnitude of acceleration due to gravity
##### Begin Editing #####
finalVelocity = (2*gravityAccMag*initialHeight)**(1/2) # in meters/s. This should be a vector.
##### End Editing #####
velocityMagnitude = np.linalg.norm(finalVelocity) #numpy.linalg.norm takes the magnitude of an array
print('The final velocity of a ball after falling 2 meters has a magnitude of {} meters/second'.format(velocityMagnitude))
#Use this cell to calculate the magnitude of the drag force for a ball that has fallen 2 meters
vel = velocityMagnitude*np.array([1./np.sqrt(3),1./np.sqrt(6),1./np.sqrt(2)]) # meters/s
print(vel)
r = 0.025 # meters
##### Begin Editing #####
A = (3.1416)*(r**2) #m^2
C = 0.5 #unitless
rho = 1.204 #kg/m^3
dragForce = (-0.5)*C*A*rho*(vel**2)
##### End Editing #####
dragMagnitude = np.linalg.norm(dragForce)
print('The magnitude of the air drag force is {}'.format(dragMagnitude))
#Run this cell without editing
print(np.linalg.norm(vel)*vel)
print(vel*vel)
#Use this cell to calculate the ratio of the magnitude of the drag force to gravity
##### Begin Editing #####
gravityForce = (0.075)*(gravityAccMag)
##### End Editing #####
gravityMagnitude = np.linalg.norm(gravityForce)
ratio = dragMagnitude / gravityMagnitude
print('The ratio of the air drag force to gravity is {}'.format(ratio))