Last active
March 24, 2016 15:20
-
-
Save steelman/3ca5d029be9b2b618764 to your computer and use it in GitHub Desktop.
Simple trilateration
This file contains 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
12 | |
8 | |
2 | |
1 54.343 948.686 | |
2 600.201 167.674 | |
1 3 208.14 | |
1 4 483.96 | |
2 4 600.74 | |
2 5 261.58 | |
2 6 395.61 | |
1 7 383.53 | |
3 7 223.61 | |
3 4 302.65 | |
6 7 216.33 | |
7 8 223.61 | |
8 3 254.56 |
This file contains 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
1 54.343 948.686 | |
2 600.201 167.674 | |
3 200 800 | |
4 500 760 | |
5 480 400 | |
6 280 400 | |
7 160 580 | |
8 380 620 |
This file contains 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
#!/usr/bin/python | |
import sys | |
import re | |
data_re = re.compile("([0-9]+)\s+([.0-9]+)\s+([.0-9]+)") | |
SurveyData = [] | |
L = int(sys.stdin.readline()) | |
N = int(sys.stdin.readline()) | |
Coordinates = [None] * (N+1) | |
for i in range(N+1): | |
SurveyData.append([None] * (N+1)) | |
M = int(sys.stdin.readline()) | |
for i in range(M): | |
line = sys.stdin.readline() | |
m = data_re.search(line) | |
pnt = int(m.group(1)) | |
x = float(m.group(2)) | |
y = float(m.group(3)) | |
Coordinates[pnt]=(x,y) | |
line = sys.stdin.readline().strip() | |
m = data_re.search(line) | |
for i in range(L): | |
#while m and len(m.groups()) == 3: | |
src_p = int(m.group(1)) | |
dst_p = int(m.group(2)) | |
dist = float(m.group(3)) | |
SurveyData[src_p][dst_p] = dist | |
SurveyData[dst_p][src_p] = dist | |
line = sys.stdin.readline().strip() | |
m = data_re.search(line) | |
print repr(SurveyData) | |
print repr(Coordinates) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment