Java Reference
In-Depth Information
Solving Triangles
Many engineering problems require the solution of triangles. The program -
ming required is simple and straightforward. The following examples are
provided as illustrations of applying Java code to the solution of simple
equations.
Pythagoras' theorem
One of the theorems of Euclidean geometry, usually attributed to the Greek
mathematician Pythagoras, states the relationship between the sides of a
right triangle, as shown in Figure 24-2 .
c
a
c=
2
2
a+b
b
Figure24-2Pythagoras'Theorem
If the values of sides a and b in Figure 24-2 are stored in variables of
type double, then the hypotenuse can be calculated as follows:
double a, b, c;
// Sides a, b, and c
...
c = Math.sqrt((a * a)+(b * b));
Side-angle problems
Sometimes the solution of a right triangle is required in terms of one side
and the adjacent angle. The tangent function can be applied to this case, as
shown in Figure 24-3 .
a
Ta n ( A ) =
b
a
a=bTan(A)
A
b
Figure 24-3 Side-Angle Formula for Right Triangle
 
Search WWH ::




Custom Search