Kirk Rader  1.0-SNAPSHOT
Static Public Member Functions | Private Member Functions | List of all members
us.rader.usingdoxygen.Pythagoras Class Reference

Permutations of the Pythagorean theorem. More...

Inheritance diagram for us.rader.usingdoxygen.Pythagoras:
Inheritance graph

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:

\[ a = \sqrt{ b^2 + c^2 } \]

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

See also
calculateHypotenuse
calculateLeg

Definition at line 34 of file Pythagoras.java.

Constructor & Destructor Documentation

◆ Pythagoras()

us.rader.usingdoxygen.Pythagoras.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  }

Member Function Documentation

◆ 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 $\sqrt{ b^2 + c^2 }$ where $a$ is b and $c$ is b.

Parameters
leg1One leg's length
leg2The other leg's length
Returns
The hypotenuse
Exceptions
IllegalArgumentExceptionThrown if either leg1 or leg2 is less than or equal to 0.0

Definition at line 65 of file Pythagoras.java.

Referenced by us.rader.usingdoxygen.test.PythagorasTest.negativeFirstLegTest(), us.rader.usingdoxygen.test.PythagorasTest.negativeSecondLegTest(), and us.rader.usingdoxygen.test.PythagorasTest.positiveLegsHypotenuseTest().

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 $\sqrt{ a^2 - b^2 }$ where $a$ is hypotenuse and $b$ is b.

Parameters
legOne leg's length
hypotenuseThe length of the hypotenuse
Returns
The length of the other leg
Exceptions
IllegalArgumentExceptionThrown 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.

Referenced by us.rader.usingdoxygen.test.PythagorasTest.hypotenuseLessThanLegTest(), us.rader.usingdoxygen.test.PythagorasTest.negativeLegTest(), and us.rader.usingdoxygen.test.PythagorasTest.positiveLegAndHypotenuseLegTest().

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: