import numpy as np rand = lambda num, t: np.random.rand(num, t) - 0.5 sin = np.sin cos = np.cos arcsin = np.arcsin arccos = np.arccos sqrt = np.sqrt pi = np.pi
defangle(x0, y0): x = x0 / sqrt(x0**2 + y0**2) y = y0 / sqrt(x0**2 + y0**2) efactor = 0.01 if y > 0: theta = arcsin(y) if cos(theta) - x < efactor: return theta else: return pi - theta else: theta = arcsin(y) + 2*pi if cos(theta) - x < efactor: return theta else: return3*pi - theta defangle(x0, y0): x = x0 / sqrt(x0**2 + y0**2) y = y0 / sqrt(x0**2 + y0**2) efactor = 0.01 if y > 0: theta = arcsin(y) if cos(theta) - x < efactor: return theta else: return pi - theta else: theta = arcsin(y) + 2*pi if cos(theta) - x < efactor: return theta else: return3*pi - theta defrand_vec(num): res = [] for x, y in rand(num, 2): res.append(Vector(x, y)) return res
definit_vec(num): vec_arr = rand_vec(num) res = [] length = 0 for vec in vec_arr: length += vec.length() for vec in vec_arr: res.append(Vector(vec.x / length, vec.y / length)) return res