diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-10-25 10:54:44 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-10-25 10:54:44 +0200 |
| commit | 50f8e9bf1997a1bd3f076046a1bae16ad610dd41 (patch) | |
| tree | af2abcf63e5745a7a5105cf6bc304df884c7d03c | |
| parent | ff6f8002c14b6a39146053d6ab15d94588963641 (diff) | |
| download | arithmeticbilliard-50f8e9bf1997a1bd3f076046a1bae16ad610dd41.tar.gz arithmeticbilliard-50f8e9bf1997a1bd3f076046a1bae16ad610dd41.zip | |
Added description of edge points ofr 3d billiards
| -rw-r--r-- | billiard3d.py | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/billiard3d.py b/billiard3d.py index b9eb143..904d094 100644 --- a/billiard3d.py +++ b/billiard3d.py | |||
| @@ -134,7 +134,7 @@ def draw_path_2d(sizes, r, transformation): | |||
| 134 | plt.plot([p[0] for p in path], [p[1] for p in path], color="blue") | 134 | plt.plot([p[0] for p in path], [p[1] for p in path], color="blue") |
| 135 | 135 | ||
| 136 | ############################################################################### | 136 | ############################################################################### |
| 137 | # This part is specific for drawing the 2d projections of 3d billiards | 137 | # This part is specific for 3d billiards |
| 138 | ############################################################################### | 138 | ############################################################################### |
| 139 | class Face: | 139 | class Face: |
| 140 | def __init__(self, fixed_coordinate, value, transformation): | 140 | def __init__(self, fixed_coordinate, value, transformation): |
| @@ -170,9 +170,6 @@ def draw_3d_projections(sizes, r): | |||
| 170 | draw_bouncing_points_3d2d(sizes, r, face) | 170 | draw_bouncing_points_3d2d(sizes, r, face) |
| 171 | plt.show() | 171 | plt.show() |
| 172 | 172 | ||
| 173 | ############################################################################### | ||
| 174 | # This part is for drawing 3d pictures | ||
| 175 | ############################################################################### | ||
| 176 | def draw_line_3d(ax, p1, p2, c="black", w=1): | 173 | def draw_line_3d(ax, p1, p2, c="black", w=1): |
| 177 | ax.plot([p1[0], p2[0]], [p1[1], p2[1]], [p1[2], p2[2]], color=c, lw=w) | 174 | ax.plot([p1[0], p2[0]], [p1[1], p2[1]], [p1[2], p2[2]], color=c, lw=w) |
| 178 | 175 | ||
| @@ -210,6 +207,41 @@ def draw_3d_picture(sizes, r): | |||
| 210 | 207 | ||
| 211 | plt.show() | 208 | plt.show() |
| 212 | 209 | ||
| 210 | def edge_number(c1, c2): | ||
| 211 | a = 0 if c1 == 0 else 1 | ||
| 212 | b = 0 if c2 == 0 else 1 | ||
| 213 | return a + 2*b | ||
| 214 | |||
| 215 | def print_points_on_edges_coord(s, path, i): | ||
| 216 | L = [[], [], [], []] | ||
| 217 | Lname = [['*','*','*'],['*','*','*'],['*','*','*'],['*','*','*']] | ||
| 218 | # Kinda ugly way of saying "j and k are the other 2 coordinates" | ||
| 219 | j = 0 if i != 0 else 1 | ||
| 220 | k = 2 if i != 2 else 1 | ||
| 221 | for p in path: | ||
| 222 | if (p[j] == 0 or p[j] == s[j]) and (p[k] == 0 or p[k] == s[k]): | ||
| 223 | en = edge_number(p[j], p[k]) | ||
| 224 | L[en].append(p[i]) | ||
| 225 | Lname[en][j] = p[j] | ||
| 226 | Lname[en][k] = p[k] | ||
| 227 | |||
| 228 | for l in range(0,4): | ||
| 229 | if len(L[l]) != 0: | ||
| 230 | so = list(set(L[l])) | ||
| 231 | so.sort() | ||
| 232 | print(len(so), "points on edge", Lname[l], ":", so) | ||
| 233 | |||
| 234 | |||
| 235 | def print_points_on_edges(size, r): | ||
| 236 | # TODO: show a picture of this | ||
| 237 | |||
| 238 | print("") | ||
| 239 | |||
| 240 | path = get_path(3, sizes, r) | ||
| 241 | for i in range(0,3): | ||
| 242 | print_points_on_edges_coord(sizes, path, i) | ||
| 243 | print("") | ||
| 244 | |||
| 213 | ############################################################################### | 245 | ############################################################################### |
| 214 | # Billiard data / user input | 246 | # Billiard data / user input |
| 215 | ############################################################################### | 247 | ############################################################################### |
| @@ -232,7 +264,11 @@ def user_input(): | |||
| 232 | #sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" | 264 | #sizes, r, pic = [2, 3, 4], [0, 0, 0], "3" |
| 233 | sizes, r, pic = user_input() | 265 | sizes, r, pic = user_input() |
| 234 | 266 | ||
| 267 | print("---------------------------------") | ||
| 235 | print_multiplicities(len(sizes), sizes, r) | 268 | print_multiplicities(len(sizes), sizes, r) |
| 269 | print("---------------------------------") | ||
| 270 | print_points_on_edges(sizes, r) | ||
| 271 | print("---------------------------------") | ||
| 236 | 272 | ||
| 237 | if pic == "p": | 273 | if pic == "p": |
| 238 | draw_3d_projections(sizes, r) | 274 | draw_3d_projections(sizes, r) |
