Fixposition SDK 0.0.0-heads/main-0-g7b59b93
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
fpsdk::common::math Namespace Reference

Math utilities. More...

Functions

template<typename T >
constexpr T Clamp (const T val, const T min, const T max)
 Clamp value in range.
 
template<typename T >
constexpr T DegToRad (T degrees)
 Convert degrees to radians.
 
template<typename T >
constexpr T RadToDeg (T radians)
 Convert radians to degrees.
 
double RoundToFracDigits (const double value, const int digits)
 Round to desired number of fractional digits (of precision)
 

Detailed Description

Math utilities.

Function Documentation

◆ Clamp()

template<typename T >
T fpsdk::common::math::Clamp ( const T val,
const T min,
const T max )
constexpr

Clamp value in range.

Template Parameters
Tnumeric type
Parameters
[in]valThe value
[in]minMinimum value
[in]maxMaximum value
Note
c++-17 has std::clamp() doing exactly (?) this...
Returns
the value clamped to the given range

Definition at line 51 of file math.hpp.

◆ DegToRad()

template<typename T >
T fpsdk::common::math::DegToRad ( T degrees)
inlineconstexpr

Convert degrees to radians.

Template Parameters
Tvalue type
Parameters
[in]degreesAngle in degrees
Returns
the angle in radians

Definition at line 65 of file math.hpp.

◆ RadToDeg()

template<typename T >
T fpsdk::common::math::RadToDeg ( T radians)
inlineconstexpr

Convert radians to degrees.

Template Parameters
Tvalue type
Parameters
[in]radiansAngle in radians
Returns
the angle in radians

Definition at line 79 of file math.hpp.

◆ RoundToFracDigits()

double fpsdk::common::math::RoundToFracDigits ( const double value,
const int digits )

Round to desired number of fractional digits (of precision)

Parameters
[in]valueThe value
[in]digitsNumber of digits (0-12), param clamped to range
Returns
the value rounded to the given number of fractional digits, or the original value if it is not finite