Created
January 3, 2012 16:43
-
-
Save twolfe18/1555704 to your computer and use it in GitHub Desktop.
get the dimensions of a video screen given its diagonal length
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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