Advertisement
imk0tter

Untitled

Aug 12th, 2023
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.47 KB | None | 0 0
  1. from math import sin, pi, cos, sqrt, acos
  2.  
  3. def RADIUS_FROM_FOV_AND_RESOLUTION(resolution_in_pixels, fov_in_degrees):
  4.   return resolution_in_pixels / sin(pi / (360 / fov_in_degrees)) / 2
  5.  
  6. def CLAMP(circle_in_half_n_units, half_n_unit):
  7.   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)
  8.  
  9. def ARCTANGENT(input_in_n_units):
  10.   return sqrt(input_in_n_units ** 2) / input_in_n_units
  11.  
  12. def TRANSDUCE(input_in_radians, size_of_circle=1):
  13.   return ARCTANGENT(input_in_radians) * acos((2 - (CLAMP(CLAMP(input_in_radians,2) / size_of_circle,2) ** 2)) / 2)
  14.  
  15. def UNTRANSDUCE(input_in_radians, size_of_circle=1):
  16.   return sqrt((size_of_circle ** 2 * 2) - (cos(input_in_radians) * (size_of_circle ** 2 * 2)))
  17.  
  18.  
  19. def Calculate_Ratio(input_in_degrees, sensitivity=1):
  20.  
  21.   # CAN BE ANY NUMBERS FOR THE PURPOSE OF CALCULATING THE RATIO
  22.   radius = RADIUS_FROM_FOV_AND_RESOLUTION(1000, 90)
  23.  
  24.   # NOT SURE HOW TO COMMENT HTE CODE BELOW BUT IT DOES WHAT IT HAS TO
  25.   radians_in_n_unit = UNTRANSDUCE(input_in_degrees / (360 / pi / 2), 1 / sensitivity)
  26.   n_unit_in_pixels = radians_in_n_unit * radius
  27.  
  28.   barrier_in_pixels = TRANSDUCE(radians_in_n_unit, 1 / sensitivity) * radius / sensitivity
  29.  
  30.   return input_in_degrees, barrier_in_pixels / n_unit_in_pixels
  31.  
  32.  
  33. # KNOWN TO WORK FROM 0.0..1 TO 180 DEGREES
  34. # Calculate_Ratio(DEGREES)
  35.  
  36. for i in range(1,181):
  37.   print(str(Calculate_Ratio(i)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement