Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Hypotenuse and Angle (B)

Status
Not open for further replies.

astrogirl77

Programmer
Aug 14, 2008
45
CA

If you only know two side lengths of a scalene triangle (but none of the angles) can you determine the third side length?


I had been using this formula to determine the length of the hypotenuse ;

SQRT ( side1^2 + side2^2)

But realized that this is meant ONLY to determine the side length of the hypotenuse for right triangles and not scalenes per se.... is there some other formla that can be used to get the line length of the hypotenuse for a scalene in the above situation?

If there isn't a way to get the 3rd line length of scalenes this way, do you know if there is a way to get the hypotenuse line length AND the angle between the hypotenuse and the base, if we have the two side lengths of the base(adjacent) and the opposite side, and if we have the associated angles for these sides?


I've tried to incorporate all I've learned so far... but I keep getting weird errors and as far as I can tell all my formulas are correct?

I've built a small VB program, am including a sample below and the critical formulas and code I'm using... if any one can shed some light on where I've gone wrong it would be so nice! :)

Here is an example ;

Accept input from three text entry boxes

1.) Value for Side (a), Adjacent Base
the value of 14 is entered

2.) Value for Side (c), Opposite
the value of 10 is entered

3.) Angle (B) [ entered as degrees ]
the value of 60 degrees is entered

The hypotenuse is computed to be ;
8.83176086632785

The arc cos function is derived ;

Public Function Arccos(X As Double) As Double
Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Its then called from code below

Pi is declared as a constant in a module
'=======================
'=======================

'Converts the entry from degrees to radians

angle_B_degree_value_radians = (angle_B_degree_value * Pi) / 180

'get hypotenuse side length and outputs it to a text box
side_b_squared = CDbl(c1 ^ 2 + a1 ^ 2 - (c1 * a1)) * Cos(angle_B_degree_value_radians)

b1 = Sqr(side_b_squared)
Text5.Text = b1

angle_C_cos_value = CDbl(a1 ^ 2 + b1 ^ 2 - c1 ^ 2) / (2 * (a1 * b1))

angle_B_cos_value = CDbl(c1 ^ 2 + a1 ^ 2 - b1 ^ 2) / (2 * (c1 * a1))

angle_A_cos_value = CDbl(b1 ^ 2 + c1 ^ 2 - a1 ^ 2) / (2 * (b1 * c1))

angle_C_acos_value = (Arccos(angle_C_cos_value))

angle_B_acos_value = (Arccos(angle_B_cos_value))

angle_A_acos_value = (Arccos(angle_A_cos_value))


angle_C_degree_value = angle_C_acos_value * 180 / Pi

angle_B_degree_value = angle_B_acos_value * 180 / Pi

angle_A_degree_value = angle_A_acos_value * 180 / Pi

'=======================
'=======================

The problem is, that

angle_B_Degree Value 38.8700377933938

is returned as a degree value very different from what I entered ( 60 ) degrees! I wanted to recompute this angle to confirm that it was working ok.... but it seems often off, so now I dont know how valid any of my calculations are! I don't understand why this is happening?

I've also tried entering angles different from 60 degrees but with the samed side length values, for instance if I enter 90 degrees or 120 degrees it jus automatically fails.... if I enter 80 degrees I also get an error back....?
 
1) Only a right angled triangle has a hypoteneuse which is defined as the side opposite the right angle.
2) A triangle that does not have a right angle does not have a hypoteneuse either.
3) When working with triangles you should always name the angles A, B and C and name the sides opposite each angle a,b and c.

In your first problem you know that a is 14, c is 10 and B is 60 degrees and you want to know what b is so you use the Cosine Rule:

a^2 = b^2 + C^2 - 2.b.c.Cos(A)

The VB code is:

Sub triangle()

Const pi = 3.14159265358979

sidec = InputBox("side c (cm) = ")
sideb = InputBox("side b (cm) = ")
anglea = InputBox("angle A (degrees) = ")

sidea = (sidec ^ 2 + sideb ^ 2 - 2 * sideb * sidec * Cos(anglea * pi / 180)) ^ 0.5

MsgBox "side a = " & sidea & "cm"

End Sub

Another good rule for triangles is the Sine Rule which is:

a/sin(A) = b/sin(C) = c/sin(C)
 
Dale, thanks! But I'm hoping to compute side b... doesn't this give me side (a);

sidea = (sidec ^ 2 + sideb ^ 2 - 2 * sideb * sidec * Cos(anglea * pi / 180)) ^ 0.5

MsgBox "side a = " & sidea & "cm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top