Skip to content

Instantly share code, notes, and snippets.

@dmitriykovalev
Created November 17, 2023 23:37
Show Gist options
  • Select an option

  • Save dmitriykovalev/a1258e1b356abf4fca1ffd296680d324 to your computer and use it in GitHub Desktop.

Select an option

Save dmitriykovalev/a1258e1b356abf4fca1ffd296680d324 to your computer and use it in GitHub Desktop.
from math import degrees, radians, tan, atan, sqrt
# Diagonal FOV
dfov = 90
# Sensor size
width, height = 4032, 3024
r = width / height
# Horizontal FOV (corresponds to width)
hfov = degrees(2 * atan(tan(radians(dfov / 2)) / sqrt(1 + 1 / (r*r))))
# Vertial FOV (corresponds to height)
vfov = degrees(2 * atan(tan(radians(dfov / 2)) / sqrt(1 + (r*r))))
print(f'dfov: {dfov:.2f}')
print(f'hfov: {hfov:.2f}')
print(f'vfov: {vfov:.2f}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment