How do you calculate the height of a triangle with only the hypotenuse and the relationship of the other two sides?

There are two types of TV: traditional, having a 4: 3 aspect ratio and widescreen, which are 16: 9. I am trying to write a function that, given the 16: 9 TV diagonal, gives a 4: 3 TV diagonal with an equivalent height. I know that you can use the Pythagorean theorem for this if I know two sides, but I only know the diagonal and the ratio.

I wrote a function that works wondering, but I was wondering if there is a better way.

My attempt:

    // 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;
            }
        }
    }
+3
source share
7 answers

Diagonal and ratio are enough: -).

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

Then d² = w² + h².

r²h² + h² = d².

h² = d²/(r² + 1), : -).

+10

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

d '- (4/3) , d - 16/9, a/b = 16/9 a/b = 4/3

+3

, , , :

diagonal(4:3) = diagonal(16:9) * 15 / sqrt(337)
+2

, . , .

, .

, .

- , , - . pythagoras .

+1

n = /, : width = diagonal/(sqrt (1 + n ^ 2))

+1

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

therefore, dividing (R ^ 2 + 1) members will give you the ratio of the diagonals between two tv with the same height.

0
source

I am not a mathematician, but it looks 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.

0
source

Source: https://habr.com/ru/post/1711254/


All Articles