Skip to content

Instantly share code, notes, and snippets.

@rhettallain
rhettallain / raspberrypipicalc.py
Created Mar 8, 2017
This is the code to run on raspberry pi for an interactive pi-day poster
View raspberrypipicalc.py
#!/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 Jan 13, 2015
Money won in a coin flipping game
View coinflipbet.py
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 Aug 13, 2014
Falling Balrog with air resistance
View balrog.py
from pylab import *
vt=54
g=9.8
K=2.24
m=68
y=0
t=0
@rhettallain
rhettallain / electric_pot_plot.py
Created Jul 14, 2014
contour plot of potential
View electric_pot_plot.py
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 Jun 27, 2014
soccer goal angular size
View goal_angular.py
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
A model of a starting train with couplings
View train_start.py
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)
###
View spring_pend_et.py
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()
View car_collisions.py
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)
View ball_list.py
from visual import *
from random import *
print(uniform(2.2,4.4))
#ball1=sphere()
n=50
i=0
View stick_rot.py
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: