#!/usr/bin/python from play import * paper_w = 750 ; paper_h = 550 paper(paper_w, paper_h, "white") real_width = 5 scale = paper_w / real_width yoffset = paper_h / 2 g = -9.8 dt = 0.003 x = 0 ; y = 0 vx = 11.56 ; vy = 3.39 t = 0 tmax = 5 drag_factor = 0.2 # bogus, supposed to be proportional to cross section area lift_factor = 0.08 spin = 100 # revs per second? top spin is positive while t < tmax: point(x*scale, y*scale + yoffset) ax = 0 ay = g v = hypot(vx, vy) # drag drag = drag_factor * v*v dragx = -vx/v * drag dragy = -vy/v * drag ax = ax + dragx ay = ay + dragy # lift upx = -vy/v upy = vx/v liftx = upx * lift_factor * spin * v lifty = upy * lift_factor * spin * v ax = ax + liftx ay = ay + lifty # adrag = fudge_drag * v x = x + vx * dt y = y + vy * dt vx = vx + ax * dt vy = vy + ay * dt t = t + dt pause() # def tree(x, y, a, r, depth): # if depth == 0: # circle(x, y, r/2, fill="green") # else: # nx = x + r*sin(a) # ny = y + r*cos(a) # line(x, y, nx, ny, width=r/6, fill="brown") # tree(nx, ny, a-30, r*3/4, depth-1) # tree(nx, ny, a+25, r*3/4, depth-1) # # for depth in range(0, 9): # tree(200, 50, 0, 70, depth) # pause() # clear()