From bb2ae96e9516882abf6a9dcedc92b2bf8a261c20 Mon Sep 17 00:00:00 2001 From: MasterRoby3 Date: Wed, 25 Oct 2023 15:55:52 +0200 Subject: [PATCH] Main Code --- main.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..711ec18 --- /dev/null +++ b/main.py @@ -0,0 +1,35 @@ +import numpy as np + +rng = np.random.default_rng() + +x_dim = 7 +y_dim = 7.3 + +d = 20.6 - 6.8 - 7 - 2.5 + +def generate_ray(): + x_start = rng.uniform(0, x_dim) + y_start = rng.uniform(0, y_dim) + + phi = rng.uniform(0, 1) * 2 * np.pi + theta = np.arccos(np.sqrt(rng.uniform(0, 1))) + + x_final = x_start + np.cos(phi) * d * np.tan(theta) + y_final = y_start + np.sin(phi) * d * np.tan(theta) + + return (0 <= x_final and x_dim >= x_final and 0 <= y_final and y_dim >= y_final) + + +num = 1000000 + +count_in = 0 + +for i in range(num): + if generate_ray(): + count_in += 1 + + +print(count_in) + + +