[Python] Complete Monitor Dimension Calculator

So, I was browsing through monitors recently and was repetitively calculating their widths and heights based upon the diagonal given and the aspect ratio. I could've made a table, graph, or something boring like that, but no. I decided I needed to brush up on my python skills too and so I hit two birds with one stone, and made this. It could probably have been done much better if I'd given it more time, but here it is (I've put periods where there would be indentations).

I like to think it looks alright too:

Here it is, feel free to nick it.

Thats handy, I just do the math but would use this in the future. Here is a post from a couple years ago.

trevsstremDec '13
More to the point lets do the math

First lets do a typical 16x9 right angle tri-angle using the Pythagoras theorem it tells us that angle a is about 29.4 degrees.

So now we take that and run it again on a 21 inch diagonal and get about 18.3 inch on the bottom which is what I think you want to be your new side, right?

now if we run the formula with a 27 inch panel we get a height of about 13.3 inches so you will have about 5 inches over hang by doing this it evens out around 39 ish inch pannel.

that is today's lesson in math, I say about and around due to different bezel sizes.

PS this is handy



You can just work out the ratio of the adjacent to opposite based upon the aspect ratio and the hypotenuse by taking either the X or Y ratio, squaring it, and dividing it by the X ratio squared and Y ratio squared.
It returns a decimal value which you can multiply the square of the hypotenuse by, then square root.

Magically rearranging simple Pythagoras, no angles needed!

That's what these are in the code:

........Width = math.sqrt((Diagonal**2) * (((YRatio**2) / ((XRatio**2)+ (YRatio**2)))))
........Height = math.sqrt((Diagonal**2) * (((XRatio**2) / ((XRatio**2)+ (YRatio**2)))))

1 Like

If you're pulling an angle out of that aren't you using trigonometry? Not Pythagoras?

Maybe, my brain just does stuff some times.

You can't do that. It's a Sin.
Why? Cos Tan.

1 Like