-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathanalyzer.py
43 lines (39 loc) · 1.26 KB
/
analyzer.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
# **********************Author Info**************************
# *@author Christopher Findeisen *
# *@contact <[email protected]> *
# *@date Mon Jan 26 18:13:38 2015 *
# ***********************************************************
from graphics import *
import time
f = open('generated_input.txt', 'r')
win = GraphWin('Coordinate Plane', 1000, 1000) # give title and dimensions
given_point_order = []
for line in f:
print line
numbers = line.split();
x = int(numbers[0])
y = int(numbers[1])
pt = Point( x, y )
pt.draw(win)
given_point_order += [x,y]
f.close()
f = open('generated_output.txt', 'r')
prev_x = -1
prev_y = -1
for index,line in enumerate(f):
# Don't choke on size as last line of output
if index == len(given_point_order)/2:
break
numbers = line.split();
pt_no = int(numbers[0]) * 2
x = given_point_order[pt_no]
y = given_point_order[pt_no+1]
if prev_x >= 0:
connection = Line(Point(prev_x,prev_y), Point(x, y))
connection.draw(win)
#if you want to see the graph traverse more slowly, uncomment this!
# time.sleep(1)
prev_x = x
prev_y = y
win.getMouse() # Pause to view result
win.close()