如果只给出斜边和其他两边的比例,你如何计算三角形的高度?

时间:2022-08-27 10:46:20

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.

有两种类型的电视:传统的宽高比为4:3,宽屏的电视为16:9。我正在尝试编写一个函数,给出16:9电视的对角线给出4:3电视的对角线,其高度相等。我知道你可以使用毕达哥拉斯定理来解决这个问题,如果我知道其中两个边,但我只知道对角线和比率。

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;
            }
        }
    }

7 个解决方案

#1


Having diagonal and ratio is enough :-).

对角线和比例就足够了:-)。

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

设d为对角线,r为比率:r = w / h。

Then d²=w²+h².

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

它遵循r²h²+h²=d²。那给了你

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

h²=d²/(r²+ 1)你可以解决:-)。

#2


如果只给出斜边和其他两边的比例,你如何计算三角形的高度?

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

其中d'是新的(4/3)对角线,d是16/9对角线,a / b = 16/9,a'/ b'= 4/3

it works for other ratios as well

它也适用于其他比率

#3


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)

#4


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

如果需要,可以使用trig。毕竟,对角线是其中一面。

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.

现在您知道另一个宽高比TV的高度 - 以及宽度 - 。您可以使用trig,或使用毕达哥拉斯来计算新的对角线。

#5


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

如果n =高度/宽度则:宽度=对角线/(sqrt(1 + n ^ 2))

#6


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

简单代数给出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.

因此除以(R ^ 2 + 1)项将给出两个相同高度的电视之间的对角线比率。

#7


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

我不是数学家,但它是这样的:

h^2 = x^2 + y^2

h ^ 2 = x ^ 2 + y ^ 2

and

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

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

Therefore

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

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

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

因为你知道你可以解决y因此也是x。

#1


Having diagonal and ratio is enough :-).

对角线和比例就足够了:-)。

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

设d为对角线,r为比率:r = w / h。

Then d²=w²+h².

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

它遵循r²h²+h²=d²。那给了你

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

h²=d²/(r²+ 1)你可以解决:-)。

#2


如果只给出斜边和其他两边的比例,你如何计算三角形的高度?

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

其中d'是新的(4/3)对角线,d是16/9对角线,a / b = 16/9,a'/ b'= 4/3

it works for other ratios as well

它也适用于其他比率

#3


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)

#4


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

如果需要,可以使用trig。毕竟,对角线是其中一面。

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.

现在您知道另一个宽高比TV的高度 - 以及宽度 - 。您可以使用trig,或使用毕达哥拉斯来计算新的对角线。

#5


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

如果n =高度/宽度则:宽度=对角线/(sqrt(1 + n ^ 2))

#6


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

简单代数给出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.

因此除以(R ^ 2 + 1)项将给出两个相同高度的电视之间的对角线比率。

#7


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

我不是数学家,但它是这样的:

h^2 = x^2 + y^2

h ^ 2 = x ^ 2 + y ^ 2

and

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

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

Therefore

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

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

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

因为你知道你可以解决y因此也是x。