imunano33  0.1.1
imunano33::MathUtil Class Reference

Utility static methods for math calculations. More...

#include <mathutil.hpp>

Static Public Member Functions

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...
 

Detailed Description

Utility static methods for math calculations.

Member Function Documentation

◆ 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
TNumber type being clamped.
Parameters
numNumber to clamp
loLower bound
hiUpper 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
num1A number to compare
num2A 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
num1A number to compare
num2A number to compare
tolTolerance 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
numThe 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
numThe number to determine if near zero
tolTolerance 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
vecThe 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
vecThe vector to determine if near zero
tolTolerance 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: