#!/usr/bin/python3 # ==================================================================== # Galileo's - acceleration of gravity experiment # -------------------------------------------------------------------- # roll a ball down a ramp. if you doubled the amount of time that # the ball rolls, it travels four times as far. # -------------------------------------------------------------------- # Note: the length of Galileo's ramp is input but ignored. it is only # used to establish the slope of the ramp. # -------------------------------------------------------------------- # From: https://www.maplesoft.com/support/help/maple/view.aspx? # path=MathApps%2FGalileosInclinedPlaneExperiment # ==================================================================== import math import numpy as np # -------------------------------------------------------------------- # ---- freefall distance (falling in a gravity well) # ---- g acceleration of gravity # ---- iv initial velocity (+ is upwards;- is downwards) # ---- t time # -------------------------------------------------------------------- def freefall_distance(g,iv,t): d = (iv*t) - ((g*t**2)/2.0) return d # -------------------------------------------------------------------- # ---- distance traveled down Galileo's ramp # ---- g acceleration of gravity # ---- h height of Galileo's ramp # ---- l length of Galileo's ramp # ---- t time # -------------------------------------------------------------------- def ramp_distance(g,h,l,t): d = ((g*h)/(2*l)) * t**2 return d # -------------------------------------------------------------------- # ---- main # -------------------------------------------------------------------- txt = ''' if you doubled the amount of time that the ball rolls, it travels four times as far.''' print(txt) # ---- freefall grav = 32.0 # acceleration of gravity (feet/sec/sec) times = [1,2,3,4] # list of times to test # ---- freefall ------------------------------------------------------ print() print('---- freefall distances ----------------') print('time (sec) dist (ft)') for t in times: d = freefall_distance(grav,0.0,t) print(f'{t:4} {abs(d):9.1f}') # ---- ramp distance (0 degrees) ------------------------------------- h = 32.0 # height of Galileo's ramp (feet) l = 32.0 # length of Galileo's ramp (feet) print() print('---- ramp distance --(90 deg vertical)--') print('time (sec) dist (ft)') for t in times: d = ramp_distance(grav,h,l,t) print(f'{t:4} {d:9.1f}') # ---- ramp distance (45 degrees) ------------------------------------ deg = 45.0 # ramp angle h = 16.0 # height of Galileo's ramp (feet) l = h/math.sin(np.deg2rad(deg)) # length of Galileo's ramp (feet) print() print(f'---- ramp distance --({deg} deg)-----------') print(f'ramp height={h:<0.1f} length={l:<7.1f}') print('time (sec) dist (ft)') for t in times: d = ramp_distance(grav,h,l,t) print(f'{t:4} {d:9.1f}') # ---- ramp distance (30 degrees) ------------------------------------ deg = 30.0 # ramp angle h = 16.0 # height of Galileo's ramp (feet) l = h/math.sin(np.deg2rad(deg)) # length of Galileo's ramp (feet) print() print(f'---- ramp distance --({deg} deg)-----------') print(f'ramp height={h:<0.1f} length={l:<7.1f}') print('time (sec) dist (ft)') for t in times: d = ramp_distance(grav,h,l,t) print(f'{t:4} {d:9.1f}') # ---- ramp distance (10 degrees) ------------------------------------ deg = 10.0 # ramp angle h = 16.0 # height of Galileo's ramp (feet) l = h/math.sin(np.deg2rad(deg)) # length of Galileo's ramp (feet) print() print(f'---- ramp distance --({deg} deg)-----------') print(f'ramp height={h:<0.1f} length={l:<7.1f}') print('time (sec) dist (ft)') for t in times: d = ramp_distance(grav,h,l,t) print(f'{t:4} {d:9.1f}')
if you doubled the amount of time that the ball rolls, it travels four times as far. ---- freefall distances ---------------- time (sec) dist (ft) 1 16.0 2 64.0 3 144.0 4 256.0 ---- ramp distance --(90 deg vertical)-- time (sec) dist (ft) 1 16.0 2 64.0 3 144.0 4 256.0 ---- ramp distance --(45.0 deg)----------- ramp height=16.0 length=22.6 time (sec) dist (ft) 1 11.3 2 45.3 3 101.8 4 181.0 ---- ramp distance --(30.0 deg)----------- ramp height=16.0 length=32.0 time (sec) dist (ft) 1 8.0 2 32.0 3 72.0 4 128.0 ---- ramp distance --(10.0 deg)----------- ramp height=16.0 length=92.1 time (sec) dist (ft) 1 2.8 2 11.1 3 25.0 4 44.5