1.14. Finding the Length of Any Three Sidesof a Right Triangle
Problem
You need to calculate the length of one side of a triangle when either the lengths of two sides are known or one angle and the length of a side are known.
Solution
Use the Math.Sin,
Math.Cos, and Math.Tan methods
of the Math class to find the length of one side.
The equations for these methods are as follows:
double theta = 40; double hypotenuse = 5; double oppositeSide; double adjacentSide; oppositeSide = Math.Sin(theta) * hypotenuse; oppositeSide = Math.Tan(theta) * adjacentSide; adjacentSide = Math.Cos(theta) * hypotenuse; adjacentSide = oppositeSide / Math.Tan(theta); hypotenuse = oppositeSide / Math.Sin(theta); hypotenuse = adjacentSide / Math.Cos(theta);
where theta (Θ) is the known angle, and the oppositeSide variable
is equal to the length of the side opposite to
the angle theta, and the
adjacentSide variable is equal to the length of
the side adjacent to the angle
theta. The hypotenuse variable
is equal to the length of the hypotenuse of the
triangle. See Figure 1-1.

Figure 1-1. A right triangle
In addition to these three static methods, the length of the hypotenuse of a right triangle can be calculated using the Pythagorean theorem. This theorem states that the hypotenuse of a right triangle is equal to the square root of the sum of the squares of the other two sides. This equation can be realized ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access