Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sin, pi, cos, sqrt, acos
- def RADIUS_FROM_FOV_AND_RESOLUTION(resolution_in_pixels, fov_in_degrees):
- return resolution_in_pixels / sin(pi / (360 / fov_in_degrees)) / 2
- def CLAMP(circle_in_half_n_units, half_n_unit):
- return ((circle_in_half_n_units / half_n_unit) - ((circle_in_half_n_units / half_n_unit) % 1)) % 2 * -half_n_unit + (circle_in_half_n_units % half_n_unit)
- def ARCTANGENT(input_in_n_units):
- return sqrt(input_in_n_units ** 2) / input_in_n_units
- def TRANSDUCE(input_in_radians, size_of_circle=1):
- return ARCTANGENT(input_in_radians) * acos((2 - (CLAMP(CLAMP(input_in_radians,2) / size_of_circle,2) ** 2)) / 2)
- def UNTRANSDUCE(input_in_radians, size_of_circle=1):
- return sqrt((size_of_circle ** 2 * 2) - (cos(input_in_radians) * (size_of_circle ** 2 * 2)))
- def Calculate_Ratio(input_in_degrees, sensitivity=1):
- # CAN BE ANY NUMBERS FOR THE PURPOSE OF CALCULATING THE RATIO
- radius = RADIUS_FROM_FOV_AND_RESOLUTION(1000, 90)
- # NOT SURE HOW TO COMMENT HTE CODE BELOW BUT IT DOES WHAT IT HAS TO
- radians_in_n_unit = UNTRANSDUCE(input_in_degrees / (360 / pi / 2), 1 / sensitivity)
- n_unit_in_pixels = radians_in_n_unit * radius
- barrier_in_pixels = TRANSDUCE(radians_in_n_unit, 1 / sensitivity) * radius / sensitivity
- return input_in_degrees, barrier_in_pixels / n_unit_in_pixels
- # KNOWN TO WORK FROM 0.0..1 TO 180 DEGREES
- # Calculate_Ratio(DEGREES)
- for i in range(1,181):
- print(str(Calculate_Ratio(i)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement