diff options
| -rw-r--r-- | __pycache__/billiard3d.cpython-311.pyc | bin | 0 -> 20190 bytes | |||
| -rw-r--r-- | billiard3d.py | 48 | ||||
| -rw-r--r-- | multiplicity_stats.py | 46 |
3 files changed, 73 insertions, 21 deletions
diff --git a/__pycache__/billiard3d.cpython-311.pyc b/__pycache__/billiard3d.cpython-311.pyc new file mode 100644 index 0000000..5c7b5cb --- /dev/null +++ b/__pycache__/billiard3d.cpython-311.pyc | |||
| Binary files differ | |||
diff --git a/billiard3d.py b/billiard3d.py index 904d094..806ae28 100644 --- a/billiard3d.py +++ b/billiard3d.py | |||
| @@ -54,11 +54,7 @@ def is_double(path): | |||
| 54 | 54 | ||
| 55 | return False | 55 | return False |
| 56 | 56 | ||
| 57 | def print_multiplicities(n, sizes, r): | 57 | def get_multiplicities(n, sizes, r): |
| 58 | print("") | ||
| 59 | print("Points with multiplicity > 1:") | ||
| 60 | print("") | ||
| 61 | |||
| 62 | d = dict() | 58 | d = dict() |
| 63 | path = [tuple(x) for x in get_path(n, sizes, r)] | 59 | path = [tuple(x) for x in get_path(n, sizes, r)] |
| 64 | 60 | ||
| @@ -72,6 +68,15 @@ def print_multiplicities(n, sizes, r): | |||
| 72 | for p in d: | 68 | for p in d: |
| 73 | d[p] //= 2 | 69 | d[p] //= 2 |
| 74 | 70 | ||
| 71 | return d | ||
| 72 | |||
| 73 | def print_multiplicities(n, sizes, r): | ||
| 74 | d = get_multiplicities(n, sizes, r) | ||
| 75 | |||
| 76 | print("") | ||
| 77 | print("Points with multiplicity > 1:") | ||
| 78 | print("") | ||
| 79 | |||
| 75 | for i in range(2, max(d.values())+1): | 80 | for i in range(2, max(d.values())+1): |
| 76 | L = [] | 81 | L = [] |
| 77 | for point in d: | 82 | for point in d: |
| @@ -259,21 +264,22 @@ def user_input(): | |||
| 259 | # Main routine below | 264 | # Main routine below |
| 260 | ############################################################################### | 265 | ############################################################################### |
| 261 | 266 | ||
| 262 | # You can choose to write your input here or to get it interactively | 267 | if __name__ == '__main__': |
| 263 | #sizes, r, pic = [15, 9, 7], [2, 0, 0], "p" | 268 | # You can choose to write your input here or to get it interactively |
| 264 | #sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" | 269 | #sizes, r, pic = [15, 9, 7], [2, 0, 0], "p" |
| 265 | sizes, r, pic = user_input() | 270 | #sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" |
| 271 | sizes, r, pic = user_input() | ||
| 266 | 272 | ||
| 267 | print("---------------------------------") | 273 | print("---------------------------------") |
| 268 | print_multiplicities(len(sizes), sizes, r) | 274 | print_multiplicities(len(sizes), sizes, r) |
| 269 | print("---------------------------------") | 275 | print("---------------------------------") |
| 270 | print_points_on_edges(sizes, r) | 276 | print_points_on_edges(sizes, r) |
| 271 | print("---------------------------------") | 277 | print("---------------------------------") |
| 272 | 278 | ||
| 273 | if pic == "p": | 279 | if pic == "p": |
| 274 | draw_3d_projections(sizes, r) | 280 | draw_3d_projections(sizes, r) |
| 275 | elif pic == "3": | 281 | elif pic == "3": |
| 276 | draw_3d_picture(sizes, r) | 282 | draw_3d_picture(sizes, r) |
| 277 | else: | 283 | else: |
| 278 | draw_3d_projections(sizes, r) | 284 | draw_3d_projections(sizes, r) |
| 279 | draw_3d_picture(sizes, r) | 285 | draw_3d_picture(sizes, r) |
diff --git a/multiplicity_stats.py b/multiplicity_stats.py new file mode 100644 index 0000000..438a2fa --- /dev/null +++ b/multiplicity_stats.py | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | import billiard3d | ||
| 2 | import sys | ||
| 3 | |||
| 4 | def get_stats(i, j, k, mult): | ||
| 5 | for r1 in range(i+1): | ||
| 6 | for r2 in range(j+1): | ||
| 7 | for r3 in range(k+1): | ||
| 8 | d = billiard3d.get_multiplicities(3, [i, j, k], [r1, r2, r3]) | ||
| 9 | for key in d: | ||
| 10 | mult[d[key]] += 1 | ||
| 11 | |||
| 12 | def print_stats(N): | ||
| 13 | mult = [0] * 10 | ||
| 14 | for i in range(1, N+1): | ||
| 15 | for j in range(i, N+1): | ||
| 16 | for k in range(j, N+1): | ||
| 17 | get_stats(i, j, k, mult) | ||
| 18 | |||
| 19 | print("Statistics for paths with 0 < a <= b <= c <= {0}".format(N)) | ||
| 20 | print("Considering all paths starting from any possible point") | ||
| 21 | for i in range(1, 10): | ||
| 22 | if mult[i] != 0: | ||
| 23 | print("Multiplicity {0}: {1} points".format(i, mult[i])) | ||
| 24 | print("There are no points of positive multiplicity different from those listed above") | ||
| 25 | |||
| 26 | def print_stats_single(a, b, c): | ||
| 27 | mult = [0] * 10 | ||
| 28 | get_stats(a, b, c, mult) | ||
| 29 | |||
| 30 | print("Statistics for paths with a={0}, b={1} and c={2}".format(a, b, c)) | ||
| 31 | print("Considering all paths starting from any possible point") | ||
| 32 | for i in range(1, 10): | ||
| 33 | if mult[i] != 0: | ||
| 34 | print("Multiplicity {0}: {1} points".format(i, mult[i])) | ||
| 35 | print("There are no points of positive multiplicity different from those listed above") | ||
| 36 | |||
| 37 | if len(sys.argv) == 2: | ||
| 38 | N = int(sys.argv[1]) | ||
| 39 | print_stats(N) | ||
| 40 | elif len(sys.argv) == 4: | ||
| 41 | a, b, c = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]) | ||
| 42 | print_stats_single(a, b, c) | ||
| 43 | else: | ||
| 44 | print("Use one of the following options:") | ||
| 45 | print("\tpython multiplicity_stats.py N\t\t # For all possible sizes up to N") | ||
| 46 | print("\tpython multiplicity_stats.py a b c\t # For all starting points for the single 3d box (a,b,c)") | ||
