-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathholesforpoles3.py
More file actions
executable file
·50 lines (43 loc) · 1.32 KB
/
holesforpoles3.py
File metadata and controls
executable file
·50 lines (43 loc) · 1.32 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
#!/usr/bin/python3
# Small utility script, to find the sweet spot for placing two poles, and
# making it look natural when adding a third pole.
#
#
# Rough sketch (Outer Margin):
#
# Partial
#
# -----------------------
# OM * * OM
#
# Whole
#
# -------------------------------
# OM * * * OM
#
whole = 7.1 # metres
partial = 4.38 # metres
# Both sides, metres
margin = 0.1
max_margin = 1.75
# How much to increment when searching for a right length
search_increment = 0.01
numbers = []
while True:
whole_ = (whole - margin) / 2
partial_ = (partial - margin) / 1
numbers.append(((whole_ - partial_), whole_, partial_, margin))
margin += search_increment
if margin > max_margin: break
best_match = min(numbers, key=lambda x: abs(x[0]))
print("Best match, margin of error: %f" % best_match[0])
print("Space between poles for whole: %f" % best_match[1])
print("Space between poles for partial: %f" % best_match[2])
outer_margin = best_match[3]
print("Outer margin: %f, %f" % (outer_margin, outer_margin/2))
print("Specified length for partial: %f" % partial)
print("Partial: Margin + space between poles: %f" %
(best_match[2] + best_match[3]))
print("Specified length for whole: %f" % whole)
print("Whole: Margin + space between poles: %f" %
((best_match[1] * 2) + best_match[3]))