Skip to content

Instantly share code, notes, and snippets.

@rhettallain
rhettallain / ball_bounce1.py
Created January 29, 2014 23:18
ball bounce with zero energy loss
from visual import *
g=vector(0,-9.8,0)
ball=sphere(pos=(0,1,0), radius=0.05, material=materials.shiny)
ball.p=vector(0,0,0)
ball.m=0.1
t=0
dt=0.001
floor = box(length=1, width=1, height=0.05, pos=vector(0,0,0), color=color.blue)
@rhettallain
rhettallain / ball_bounce2.py
Created January 29, 2014 23:20
ball bounce with energy lost
from visual import *
g=vector(0,-9.8,0)
ball=sphere(pos=(0,1,0), radius=0.05, material=materials.shiny)
ball.p=vector(0,0,0)
ball.m=0.1
t=0
dt=0.001
floor = box(length=1, width=1, height=0.05, pos=vector(0,0,0), color=color.blue)
@rhettallain
rhettallain / fake_bounce1.py
Created January 29, 2014 23:24
this isn't realistic bounce
from visual import *
g=vector(0,-9.8,0)
h=1
ball=sphere(pos=(0,h,0), radius=0.05, material=materials.shiny)
ball.p=vector(0,0,0)
ball.m=0.1
t=0
dt=0.001
@rhettallain
rhettallain / fake_ball_bounce2.py
Created January 30, 2014 14:27
Here is another ball bounce animation
from visual import *
g=vector(0,-9.8,0)
h=1
ball=sphere(pos=(0,h,0), radius=0.05, material=materials.shiny)
ball.p=vector(0,-.0003,0)
ball.m=0.1
t=0
dt=0.001
@rhettallain
rhettallain / coriolis_kick.py
Last active August 29, 2015 13:56
vpython calculation of the trajectory of a football with the Coriolis force
from visual import *
from visual.graph import *
fun1=gcurve(color=color.cyan)
v0=30
thetan=11*pi/180
theta=40*pi/180
ab=vector(1,3,-3.4)
print(ab)
g=vector(0,-9.8,0)
A=0.027
@rhettallain
rhettallain / electric_collision.py
Created February 6, 2014 15:12
Practice collisions
from visual import *
from visual.graph import *
f1=gcurve(color=color.cyan)
f2=gcurve(color=color.yellow)
f3=gcurve(color=color.red)
K=1
ball1=sphere(pos=(-3, 0,0), radius=.1, color=color.yellow, make_trail=True)
ball2=sphere(pos=(0,0,0), radius=.1, color=color.yellow, make_trail=True)
@rhettallain
rhettallain / flappy_random.py
Created February 9, 2014 23:25
simulation of flappy bird
from pylab import *
import random as rd
total=150
p=.587
np=[]
sp=[]
n=0
@rhettallain
rhettallain / brad.py
Created February 12, 2014 15:58
Brad's program
from visual import *
from visual.graph import *
fun1=gcurve(color=color.cyan)
fun2=gcurve(color=color.red)
fun3=gcurve(color=color.yellow)
ball=sphere(pos=(1,-2,3), radius=0.1, color=color.yellow, make_trail=True)
ball.v=vector(0,0,0)
@rhettallain
rhettallain / whiletest.py
Created February 18, 2014 16:26
example of a while loop
a=True
x=0
dx=0.1
while a:
x=x+dx
if x>=0.7:
a=False
print('hello')
print(x)
@rhettallain
rhettallain / function_ex.py
Created February 20, 2014 16:03
An example using function
from __future__ import division
from visual import *
from visual.graph import *
fun1=gcurve(color=color.cyan)
def spring1(k,x0,v0,m):
# x0=.2
ball=sphere(pos=(x0,0,0), radius=0.05)