Skip to content

Instantly share code, notes, and snippets.

@rhettallain
rhettallain / raspberrypipicalc.py
Created March 8, 2017 20:49
This is the code to run on raspberry pi for an interactive pi-day poster
#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or BeagleBone Black.
import time
import Adafruit_CharLCD as LCD
import Adafruit_CharLCD as LCD
import turtle
import random
from math import sqrt
from gpiozero import Button
@rhettallain
rhettallain / coinflipbet.py
Created January 13, 2015 14:24
Money won in a coin flipping game
import plotly.plotly as py
from plotly.graph_objs import *
from random import *
from pylab import *
py.sign_in("yourusername", "plotlykey") #you need a plotly account
def flip(N,lose,win):
@rhettallain
rhettallain / balrog.py
Created August 13, 2014 14:01
Falling Balrog with air resistance
from pylab import *
vt=54
g=9.8
K=2.24
m=68
y=0
t=0
@rhettallain
rhettallain / electric_pot_plot.py
Created July 14, 2014 18:48
contour plot of potential
import plotly.plotly as py
from plotly.graph_objs import *
from pylab import *
from visual import vector, norm, mag
#you need to add your own plot.ly credentials here
#py.sign_in(###########)
#electric constant
k=9e9
@rhettallain
rhettallain / goal_angular.py
Created June 27, 2014 14:05
soccer goal angular size
from pylab import *
#from visual import vector, dot, mag
## mark out the pitch
xlist=linspace(0,50.0,500)
ylist=linspace(-35.0, 35.0, 350)
X,Y = meshgrid(xlist, ylist)
@rhettallain
rhettallain / train_start.py
Created May 28, 2014 15:27
A model of a starting train with couplings
from visual import *
from visual.graph import *
## Setting up graphs for three of the cars
fun1=gcurve(color=color.cyan)
fun2=gcurve(color=color.yellow)
fun3=gcurve(color=color.red)
###
from pylab import *
#graph1 = gdisplay(title='Vertical Position vs. Time', xtitle ='t (sec)', ytitle ='y (m)', background=color.white)
#funct1=gcurve(color=color.white)
#floor = box (pos=(0,0,0), length=.4, height=0.05, width=.4, color=color.blue)
L = 120
theta0 = -pi/2
#ball2=sphere()
@rhettallain
rhettallain / car_collisions.py
Created April 14, 2014 15:23
collision physics
from visual import *
from visual.graph import *
fun1=gcurve(color=color.red)
fun2=gcurve(color=color.blue)
fun3=gcurve(color=color.yellow)
car1=box(pos=(-0.25, 0, 0), height=0.05, width=0.05, length=0.12, color=color.red)
car2=box(pos=(0.1, 0, 0), height=0.05, width=0.05, length=0.12, color=color.blue)
@rhettallain
rhettallain / ball_list.py
Created March 27, 2014 13:38
list of spheres
from visual import *
from random import *
print(uniform(2.2,4.4))
#ball1=sphere()
n=50
i=0
@rhettallain
rhettallain / stick_rot.py
Created March 25, 2014 14:22
rotating stick
from visual import *
stick=box(pos=(0,0,0), length=1, width=.2, height=.2, color=color.cyan)
w=.5
t=0
dt=0.01
while True: