Regenerated PDF

This commit is contained in:
Roger Labbe 2015-05-01 07:05:53 -07:00
parent 4fef1138f7
commit 08123b0d15
4 changed files with 80 additions and 2 deletions

View File

@ -388,7 +388,8 @@
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
"collapsed": false,
"scrolled": true
},
"outputs": [
{

View File

@ -102,7 +102,7 @@
" color: #1d3b84;\n",
" font-size: 16pt;\n",
" margin-bottom: 0em;\n",
" margin-top: 1.5em;\n",
" margin-top: 0.5em;\n",
" display: block;\n",
" white-space: nowrap;\n",
" }\n",
@ -126,6 +126,11 @@
" overflow-y: scroll;\n",
" max-height: 50000px;\n",
" }\n",
" div.output_wrapper{\n",
" margin-top:0.2em;\n",
" margin-bottom:0.2em;\n",
"}\n",
"\n",
" code{\n",
" font-size: 70%;\n",
" }\n",

46
experiments/bicycle.py Normal file
View File

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 08:19:21 2015
@author: Roger
"""
from math import *
import numpy as np
import matplotlib.pyplot as plt
wheelbase = 100 #inches
vel = 20 *12 # fps to inches per sec
steering_angle = radians(1)
t = 1 # second
orientation = 0. # radians
pos = np.array([0., 0.])
for i in range(100):
#if abs(steering_angle) > 1.e-8:
dist = vel*t
turn_radius = tan(steering_angle)
radius = wheelbase / tan(steering_angle)
arc_len = dist / (2*pi*radius)
turn_angle = 2*pi * arc_len
cx = pos[0] - (sin(orientation) * radius)
cy = pos[1] + (cos(orientation) * radius)
orientation = (orientation + turn_angle) % (2.0 * pi)
pos[0] = cx + (sin(orientation) * radius)
pos[1] = cy - (cos(orientation) * radius)
plt.scatter(pos[0], pos[1])
plt.axis('equal')

26
experiments/euler.py Normal file
View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 21 18:40:47 2015
@author: Roger
"""
def dx(t, y):
return y
def euler(t0, tmax, y0, dx, step=1.):
t = t0
y = y0
while t < tmax:
f = dx(t,y)
y = y + step*dx(t, y)
t +=step
return y
print(euler(0, 4, 1, dx, step=0.25))