Created
February 27, 2011 17:25
-
-
Save jplattel/846349 to your computer and use it in GitHub Desktop.
MacLogger script takes a log with comma separated coordinates and measures the distances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#stop alle posities in een lijst | |
positions0 = [] | |
data = open("log2.txt","r") | |
for line in data: | |
position = line.replace('\n','').split(',') | |
positions0.append(position) | |
data.close | |
#print de lijst, maximale grootte: 536,870,912 items | |
positions1 = positions0 | |
total = 0 | |
logfile = open("log3.txt", "a") | |
for position in positions0: | |
position1 = positions1.pop(0) | |
x1 = int(position1[0]) | |
y1 = int(position1[1]) | |
position2 = positions1.pop(0) | |
x2 = int(position2[0]) | |
y2 = int(position2[1]) | |
logfile.write(str(x1) +','+ str(y1) +','+ str(x2) +','+ str(y2) + '\n') | |
#use pythagoras to get the distance between each measurement | |
distance = ((x1 - x2)**2 + (y1 - y2)**2)**.5 | |
#put position 2 back so we can use it again for the next loop | |
positions1.insert(0, position2) | |
total = total + distance | |
logfile.close() | |
print total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment