-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHyperbolicSolver.py
More file actions
124 lines (58 loc) · 2.43 KB
/
HyperbolicSolver.py
File metadata and controls
124 lines (58 loc) · 2.43 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 12 17:04:19 2019
@author: ckuli
"""
import math
import random
def dist(a,b):
return 2 * math.log((math.sqrt((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2) + math.sqrt((b[0] - a[0]) ** 2 + (b[1] + a[1]) ** 2)) / (2 * math.sqrt(a[1] * b[1])))
def genOrdering(circP):
ordering = []
dists = []
tdists = []
for p in points:
dists.append(dist(circP,p))
tdists.append(dist(circP,p))
while len(tdists) > 0:
minD = min(tdists)
ordering.append(dists.index(minD))
tdists.remove(minD)
return ordering
numPoints = 700000
RAD = 50.0
n = 4
while True:
#Generate random established points in a box region.
num = n
#rawPoints = raw_input("Enter your points x,y in a space-separated list: ")
#points = [[2.5614935635339853, 0.22052234976046492], [0.8430424740470159, -2.1244519018107537], [2.78617998617099, 1.4725559638474532], [1.4654636505914906, -1.201047544997071]]
points = []
for i in range(n):
x = random.uniform(-25.0,25.0)
y = random.uniform(0.1,25.0)
points.append([x,y])
#print("------- computing data for " + str(num) + " points ------- " )
orderings = []
pointsOrder = []
for i in range(numPoints):
x = random.uniform(-RAD,RAD)
y = random.uniform(0.1,RAD)
circP = [x,y]
order = genOrdering(circP)
if order not in orderings:
orderings.append(order)
pointsOrder.append(circP)
"""if len(orderings) >= 17:
print(points)
print(orderings)
index = orderings.index([2,0,1,3])
print(pointsOrder[index])
print(dist(pointsOrder[index],points[0]))
print(dist(pointsOrder[index],points[1]))
print(dist(pointsOrder[index],points[2]))
print(dist(pointsOrder[index],points[3]))
print(genOrdering(pointsOrder[index]))
"""
print("n = " + str(n) + " yields: " + str(len(orderings)))
#n += 1