Skip to content

Instantly share code, notes, and snippets.

@mik30s
Created November 20, 2018 03:49
Show Gist options
  • Save mik30s/96ed2b850a64dcf5e49040355bd720ac to your computer and use it in GitHub Desktop.
Save mik30s/96ed2b850a64dcf5e49040355bd720ac to your computer and use it in GitHub Desktop.
range = 30
#l = float(prompt("Launch force: "))
M = 7.2#float(prompt("mass: "))
vso = float(prompt("initial velocity: "))
th = radians(47.3)#float(prompt("launch angle: "))
r = 0.5#float(prompt("radius of sphere: "))
eta = 0.6#float(prompt("viscosity: "))
speed = 50#int(prompt("speed: `"))
g = 9.8
t = 0
vo = vector(vso*cos(th),vso*sin(th),0)
body = sphere(pos=vector(0,0,0), radius=r, color=vector(0,1,0), make_trail=True)
ground = box(pos=vector(0, 0, 0), size=vector(100, 0.5, 1), color=color.white)
dt = 0.1
zero = vector(0,0,0)
while True:
#launch_force = vector(l*cos(th),l*sin(th),0)
weight = vector(0,-M*g*dt,0)
drag_force = -6*pi*eta*r*vo
accl = (drag_force+weight)*(1/M)
body.pos = body.pos + vo*dt
vo = vo + accl*dt
t = t + dt
range = body.pos.x
ground.size.x = range*3
if body.pos.y < 0.1:
break
rate(speed)
print(range)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment