Permutations of the Pythagorean theorem. More...

## Static Public Member Functions

static double calculateHypotenuse (final double leg1, final double leg2)
Calculate the hypotenuse of a right triangle whose legs are of lengths leg1 and leg2. More...

static double calculateLeg (final double leg, final double hypotenuse)
Calculate the length of the remaining leg of a right triangle given the length of one leg and its hypotenuse. More...

## Private Member Functions

Pythagoras ()
Hidden constructor for utility class. More...

## Detailed Description

Permutations of the Pythagorean theorem.

The basic theorem is:

where is the hypotenuse of a right triangle and , are its legs (the sides which form a 90° angle).

calculateHypotenuse
calculateLeg

Definition at line 34 of file Pythagoras.java.

## ◆ Pythagoras()

private

Hidden constructor for utility class.

Definition at line 39 of file Pythagoras.java.

39  {
40
41  throw new IllegalStateException("do not instantiate utilit classes");
42
43  }

## ◆ calculateHypotenuse()

 static double us.rader.usingdoxygen.Pythagoras.calculateHypotenuse ( final double leg1, final double leg2 )
static

Calculate the hypotenuse of a right triangle whose legs are of lengths leg1 and leg2.

This returns where is b and is b.

Parameters
 leg1 One leg's length leg2 The other leg's length
Returns
The hypotenuse
Exceptions
 IllegalArgumentException Thrown if either leg1 or leg2 is less than or equal to 0.0

Definition at line 65 of file Pythagoras.java.

65  {
66
67  if (leg1 <= 0.0) {
68
69  throw new IllegalArgumentException("a must be positive");
70
71  }
72
73  if (leg2 <= 0.0) {
74
75  throw new IllegalArgumentException("b must be positive");
76
77  }
78
79  return Math.sqrt(leg1 * leg1 + leg2 * leg2);
80
81  }

## ◆ calculateLeg()

 static double us.rader.usingdoxygen.Pythagoras.calculateLeg ( final double leg, final double hypotenuse )
static

Calculate the length of the remaining leg of a right triangle given the length of one leg and its hypotenuse.

This returns where is hypotenuse and is b.

Parameters
 leg One leg's length hypotenuse The length of the hypotenuse
Returns
The length of the other leg
Exceptions
 IllegalArgumentException Thrown if either leg is less than or equal to 0.0 or hypotenuse is than or equal to leg

Definition at line 106 of file Pythagoras.java.

107  {
108
109  if (leg <= 0.0) {
110
111  throw new IllegalArgumentException("l must be positive");
112
113  }
114
115  if (hypotenuse <= leg) {
116
117  throw new IllegalArgumentException("h must be greater than l");
118
119  }
120
121  return Math.sqrt(hypotenuse * hypotenuse - leg * leg);
122
123  }

The documentation for this class was generated from the following file: