Utility static methods for math calculations.
More...
#include <mathutil.hpp>
|
static bool | nearZero (const num_t num) |
| Determines if number is near zero with given precision. More...
|
|
static bool | nearZero (const num_t num, const num_t tol) |
| Determines if number is near zero with given precision. More...
|
|
static bool | nearZero (const Vector3D &vec) |
| Determines if vector is near zero with given precision. More...
|
|
static bool | nearZero (const Vector3D &vec, const num_t tol) |
| Determines if vector is near zero with given precision. More...
|
|
static bool | nearEq (const num_t num1, const num_t num2) |
| Determines if num1 is nearly equal to num2. More...
|
|
static bool | nearEq (const num_t num1, const num_t num2, const num_t tol) |
| Determines if num1 is nearly equal to num2. More...
|
|
template<typename T > |
static T | clamp (const T &num, const T &lo, const T &hi) |
| Restricts num between lo and hi. More...
|
|
Utility static methods for math calculations.
◆ clamp()
template<typename T >
static T imunano33::MathUtil::clamp |
( |
const T & |
num, |
|
|
const T & |
lo, |
|
|
const T & |
hi |
|
) |
| |
|
inlinestatic |
Restricts num between lo and hi.
If num < lo, returns lo, if num > hi, returns hi, otherwise returns num. If lo > hi, then behavior is undefined.
- Template Parameters
-
T | Number type being clamped. |
- Parameters
-
num | Number to clamp |
lo | Lower bound |
hi | Upper bound |
- Returns
- Clamped number
◆ nearEq() [1/2]
static bool imunano33::MathUtil::nearEq |
( |
const num_t |
num1, |
|
|
const num_t |
num2 |
|
) |
| |
|
inlinestatic |
Determines if num1 is nearly equal to num2.
The tolerance is 0.00001.
This is helpful for comparing the equality of floating point numbers.
- Parameters
-
num1 | A number to compare |
num2 | A number to compare |
- Returns
- If the numbers are near each other such that they can be counted as equal.
◆ nearEq() [2/2]
static bool imunano33::MathUtil::nearEq |
( |
const num_t |
num1, |
|
|
const num_t |
num2, |
|
|
const num_t |
tol |
|
) |
| |
|
inlinestatic |
Determines if num1 is nearly equal to num2.
This is helpful for comparing the equality of floating point numbers.
- Parameters
-
num1 | A number to compare |
num2 | A number to compare |
tol | Tolerance within zero such that a number strictly less than this tolerance is counted as zero. |
- Returns
- If the numbers are near each other such that they can be counted as equal.
◆ nearZero() [1/4]
static bool imunano33::MathUtil::nearZero |
( |
const num_t |
num | ) |
|
|
inlinestatic |
Determines if number is near zero with given precision.
The tolerance is 0.00001.
- Parameters
-
num | The number to determine if near zero |
- Returns
- if the num is near zero
◆ nearZero() [2/4]
static bool imunano33::MathUtil::nearZero |
( |
const num_t |
num, |
|
|
const num_t |
tol |
|
) |
| |
|
inlinestatic |
Determines if number is near zero with given precision.
- Parameters
-
num | The number to determine if near zero |
tol | Tolerance within zero such that a number strictly less than this tolerance is counted as zero. |
- Returns
- if the num is near zero
◆ nearZero() [3/4]
static bool imunano33::MathUtil::nearZero |
( |
const Vector3D & |
vec | ) |
|
|
inlinestatic |
Determines if vector is near zero with given precision.
The tolerance is 0.00001.
- Parameters
-
vec | The vector to determine if near zero |
- Returns
- if the vector is near zero
◆ nearZero() [4/4]
static bool imunano33::MathUtil::nearZero |
( |
const Vector3D & |
vec, |
|
|
const num_t |
tol |
|
) |
| |
|
inlinestatic |
Determines if vector is near zero with given precision.
- Parameters
-
vec | The vector to determine if near zero |
tol | Tolerance within zero such that a number strictly less than this tolerance is counted as zero. |
- Returns
- if the vector is near zero
The documentation for this class was generated from the following file:
- /home/runner/work/imunano33/imunano33/include/imunano33/mathutil.hpp