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 a and b. 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 $hypotenuse = \sqrt{ leg_1^{(2)} + leg_2^{(2)} }$ where $leg_1$ and $leg_2$ are two sides of a triangle which form a 90° angle.

See also
calculateHypotenuse
calculateLeg

Definition at line 29 of file Pythagoras.java.

Constructor & Destructor Documentation

◆ Pythagoras()

us.rader.usingdoxygen.Pythagoras.Pythagoras ( )
private

Hidden constructor for utility class.

Definition at line 34 of file Pythagoras.java.

34  {
35 
36  throw new IllegalStateException("do not instantiate utilit classes");
37 
38  }

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 a and b.

This returns $\sqrt{ leg_{1}^{(2)} + leg_{2}^{(2)} }$

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

Definition at line 59 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().

59  {
60 
61  if (leg1 <= 0.0) {
62 
63  throw new IllegalArgumentException("a must be positive");
64 
65  }
66 
67  if (leg2 <= 0.0) {
68 
69  throw new IllegalArgumentException("b must be positive");
70 
71  }
72 
73  return Math.sqrt(leg1 * leg1 + leg2 * leg2);
74 
75  }

◆ 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{ hypotenuse^2 - leg^2 }$

Parameters
legOne leg's length
hypotenuseThe length of the hypotenuse
Returns
The length of the other leg
Exceptions
IllegalArgumentExceptionThrown if either l is less than or equal to 0.0 or h is than or equal to l

Definition at line 99 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().

99  {
100 
101  if (leg <= 0.0) {
102 
103  throw new IllegalArgumentException("l must be positive");
104 
105  }
106 
107  if (hypotenuse <= leg) {
108 
109  throw new IllegalArgumentException("h must be greater than l");
110 
111  }
112 
113  return Math.sqrt(hypotenuse * hypotenuse - leg * leg);
114 
115  }

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