-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathd10_solver.py
More file actions
37 lines (30 loc) · 944 Bytes
/
Copy pathd10_solver.py
File metadata and controls
37 lines (30 loc) · 944 Bytes
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
import math
def solve_d10():
W = 72
H = 72
# Z of side vertex to form a pentagon of width W:
Z_s = 0.5 * W / math.tan(math.radians(36))
# We know p * H * math.sin(theta) = Z_s
# And tan^2(theta) = (1 - p) / (2 * p)
# Let's search for p in (0, 1)
best_p = None
best_theta = None
min_diff = float('inf')
for i in range(1, 999):
p = i / 1000.0
val = Z_s / (p * H)
if val >= 1:
continue
theta_sin = math.asin(val)
tan_sq_expected = (1 - p) / (2 * p)
tan_sq_actual = math.tan(theta_sin)**2
diff = abs(tan_sq_expected - tan_sq_actual)
if diff < min_diff:
min_diff = diff
best_p = p
best_theta = theta_sin
print(f"Best p: {best_p}")
print(f"Best theta: {math.degrees(best_theta)}")
tz = best_p * H * math.tan(best_theta)
print(f"tz: {tz}")
solve_d10()