Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 300.754178236262248 103.453277023380423 0,276.62980277988612 90.123295023340319 0,269.345711570634421 103.319531391674346 0,293.447811515317824 116.649513392506364 0,300.754178236262248 103.453277023380423 0
- import math
- def calc(x1, y1, x2, y2):
- dist = math.sqrt((x2-x1)**2 + (y2-y1)**2)
- return dist
- li = []
- res = []
- with open("/Users/jin/points.txt") as filestream:
- for line in filestream:
- temp = line.split(",") #splits by the comma in a single list
- for i in temp:
- temp = i.split(" ") #splits by spaces to individual lists of points
- li.append(temp) #list of lists containing each point
- # for item in li:
- # x1 = item[1]
- # y1 = item[0]
- # for item in li:
- # for pt in item:
- # print pt
- for index in range(len(li)-1):
- one = li[index]
- two = li[index+1]
- x1 = float(one[0])
- y1 = float(one[1])
- x2 = float(two[0])
- y2 = float(two[1])
- res.append(calc(x1, y1, x2, y2))
- print res
Add Comment
Please, Sign In to add comment