# pi = C / d # pi = C when d = 1 from math import sin as sinr, radians, pi from time import sleep sin = lambda a: sinr(radians(a)) def get_inner_circumference(sides): inner_angle = 360 / sides other_angles = (180 - inner_angle) / 2 side = (sin(inner_angle) * 0.5) / sin(other_angles) return side * sides def get_outer_circumference(sides): inner_angle = 360 / sides other_angles = (180 - inner_angle) / 2 cross_bar = get_inner_circumference(sides) / sides other_angles = 90 - other_angles vertex_angle = 180 - (2 * other_angles) half_side = (sin(other_angles) * cross_bar) / sin(vertex_angle) return half_side * sides * 2 def get_circumference(sides): inner = get_inner_circumference(sides) outer = get_outer_circumference(sides) return (inner + outer) / 2
def sin(angle): return sinr(radians(angle))
from math import sqrt, sin as sinr, cos as cosr, atan as atanr, radians, degrees sin = lambda x: sinr(radians(x)) cos = lambda x: cosr(radians(x)) atan = lambda x: degrees(atanr(x)) def from_polar(size, angle): return [sin(angle) * size, cos(angle) * size] def to_polar(a): return {"size": size(a), "angle": angle(a)} def size(a): return sqrt(sum(val**2 for val in a)) def angle(a): return 90 if a[1] == 0 else atan(a[0] / a[1]) def _vectorise_binary(func): def new_func(a, b): try: return [func(val_a, val_b) for val_a, val_b in zip(a, b)] except TypeError: return [func(val, b) for val in a] return new_func
def sin(a): return sinr(rad(a))