-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotParticles.py
61 lines (53 loc) · 1.62 KB
/
plotParticles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import time
import sys
import random
from math import *
initX = 500
initY = 120
initTheta = 0
distance10 = 500/4
rotate90 = 90
eSigma = 500/8
fSigma = 10
gSigma = 30
def getNewX(point):
return point[0] + (distance10 + random.gauss(0, eSigma)) * math.cos(math.radians(point[2]))
def getNewY(point):
return point[0] + (distance10 + random.gauss(0, eSigma)) * math.sin(math.radians(point[2]))
def getNewThetaStraight(point):
return point[2] + fSigma
# draws the square
print "are you here?"
line1 = (500, 120, 1000, 120) # (x0, y0, x1, y1)
line2 = (1000, 120, 1000, 620) # (x0, y0, x1, y1)
line3 = (1000, 620, 500, 620) # (x0, y0, x1, y1)
line4 = (500, 620, 500, 120) # (x0, y0, x1, y1)
print "drawLine:" + str(line1)
print "drawLine:" + str(line2)
print "drawLine:" + str(line3)
print "drawLine:" + str(line4)
numberOfParticles = 100
def draw_square_plot(interface):
particles = [(initX, initY, initTheta) for i in range(numberOfParticles)]
forward_10(interface)
particles = [(getNewX(particles[i]), getNewY(particles[i]), getNewTheta(particles[i])) for i in range(numberOfParticles)]
print "drawParticles:" + str(particles)
forward_10(interface)
forward_10(interface)
forward_10(interface)
right90deg(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
right90deg(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
right90deg(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
forward_10(interface)
right90deg(interface)