Skip to content

Instantly share code, notes, and snippets.

@twolfe18
Created January 3, 2012 16:43
Show Gist options
  • Save twolfe18/1555704 to your computer and use it in GitHub Desktop.
Save twolfe18/1555704 to your computer and use it in GitHub Desktop.
get the dimensions of a video screen given its diagonal length
import sys, math
if len(sys.argv) != 2:
print 'provide a diagonal length'
exit(0)
diag = float(sys.argv[1])
# x*x + y*y = diag^2
# x*ar = y
# x*x + ar*ar*x*x = diag^2
# (1+ar*ar)*x*x = diag^2
ar = 16.0 / 9.0
s = pow(diag, 2.0) / (1.0 + pow(ar, 2.0))
x = math.sqrt(s)
y = ar * x
print round(x, 1), '\t', round(y, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment