tags:

views:

877

answers:

7

There are two sorts of TV: Traditional ones that have an aspect ratio of 4:3 and wide screen ones that are 16:9. I am trying to write a function that given the diagonal of a 16:9 TV gives the diagonal of a 4:3 TV with the equivalent height. I know that you can use Pythagoras' theorem to work this out if I know two of the sides, but I only know the diagonal and the ratio.

I have written a function that works by guessing, but I was wondering if there is a better way.

My attempt so far:

    // C#
    public static void Main()    
    {
        /*
         * h = height
         * w = width
         * d = diagonal
         */

        const double maxGuess = 40.0;
        const double accuracy = 0.0001;
        const double target = 21.5;
        double ratio4by3 = 4.0 / 3.0;
        double ratio16by9 = 16.0 / 9.0;

        for (double h = 1; h < maxGuess; h += accuracy)
        {
            double w = h * ratio16by9;
            double d = Math.Sqrt(Math.Pow(h, 2.0) + Math.Pow(w, 2.0));

            if (d >= target)
            {
                double h1 = h;
                double w1 = h1 * ratio4by3;
                double d1 = Math.Sqrt(Math.Pow(h1, 2.0) + Math.Pow(w1, 2.0));

                Console.WriteLine(" 4:3 Width: {0:0.00} Height: {1:00} Diag: {2:0.00}", w, h, d);
                Console.WriteLine("16:9 Width: {0:0.00} Height: {1:00} Diag: {2:0.00}", w1, h1, d1);

                return;
            }
        }
    }
+8  A: 

Having diagonal and ratio is enough :-).

Let d be the diagonal, r the ratio: r=w/h.

Then d²=w²+h².

It follows r²h²+h²=d². That gives you

h²= d² /( r²+1) which you can solve :-).

sleske
fixed a typo there. c != d.
Jonathan Fingland
Thanks for fixing :-).
sleske
A: 

Simple algebra gives d^2 = (R^2 + 1) h^2

so dividing the (R^2 + 1) terms will give you the ratio of diagonals between two tvs of the same height.

Visage
A: 

I'm not a mathematician, but it goes something like this:

h^2 = x^2 + y^2

and

x/y = 4/3 => x = 4/3*y

Therefore

h^2 = (4/3y)^2 + y^2

And since you know h you can solve y and therefore also x.

Makis
+1  A: 

You can use trig if you want. The diagonal is one of the sides, after all.

If you know the ratio, you know the angles.

If you know the angles and the hypotenuse you can calculate the height.

Now you know the height - and so the width - of the other aspect ratio TV. You could stay with trig, or use pythagoras to calculate the new diagonal.

Johan
double h = d * Math.Sin(Math.Atan(9.0 / 16));
Martin Brown
+1  A: 

If n = height/width then: width = diagonal /(sqrt(1 + n^2))

Naveen
+3  A: 

d' = d \sqrt{\frac{(\frac{a'}{b'})^2 + 1}{(\frac{a}{b})^2 + 1}}

where d' is the new (4/3) diagonal and d is the 16/9 diagonal, a/b = 16/9 and a'/b' = 4/3

it works for other ratios as well

cube
I think you need to square the ds
Patrick McDonald
Corrected it. Thanks.
cube
Looks like something went wrong whith the formular rendering.
Martin Brown
+2  A: 

Solving the equations already calculated in the other answers gives that for a fixed height the diagonals are in a simple ratio:

diagonal(4:3) = diagonal(16:9) * 15 / sqrt(337)
Patrick McDonald
Shame I can't accept two answers.
Martin Brown
Well I think you accepted the best answer as it 'does the math', I just took it a step further
Patrick McDonald
diagonal(4:3) = diagonal(16:9) * 0.817102066054265
Martin Brown
diagonal(4:3) = diagonal(16:9) * 0.81710206605426495393880057204928
Patrick McDonald