31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import math
|
|
|
|
|
|
def hfov_to_vfov(hFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(math.tan(math.radians(hFOV / 2)) / aspect_ratio))
|
|
|
|
def hfov_to_dfov(hFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(math.sqrt(1 + (1 / aspect_ratio)**2) * math.tan(math.radians(hFOV / 2))))
|
|
|
|
def vfov_to_hfov(vFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(aspect_ratio * math.tan(math.radians(vFOV / 2))))
|
|
|
|
def vfov_to_dfov(vFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(math.sqrt(1 + aspect_ratio**2) * math.tan(math.radians(vFOV / 2))))
|
|
|
|
def dfov_to_hfov(dFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(math.tan(math.radians(dFOV / 2)) / math.sqrt(1 + (1 / aspect_ratio)**2)))
|
|
|
|
def dfov_to_vfov(dFOV, aspect_ratio):
|
|
return 2 * math.degrees(math.atan(math.tan(math.radians(dFOV / 2)) / math.sqrt(1 + aspect_ratio**2)))
|
|
|
|
fov = 60
|
|
aspect_ratio = 2/1
|
|
|
|
print("h2v:", hfov_to_vfov(fov, aspect_ratio))
|
|
print("h2d:", hfov_to_dfov(fov, aspect_ratio))
|
|
print("v2h:", vfov_to_hfov(fov, aspect_ratio))
|
|
print("v2d:", vfov_to_dfov(fov, aspect_ratio))
|
|
print("d2h:", dfov_to_hfov(fov, aspect_ratio))
|
|
print("d2v:", dfov_to_vfov(fov, aspect_ratio))
|