Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
math.h File Reference
#include <array>
#include <cmath>
#include <misc/global.h>
#include <random>
Include dependency graph for misc/gen/math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  sf
 
namespace  sf::numbers
 

Functions

template<typename T >
sf::round (T value, T rnd)
 Rounds the passed value to a multiple of the rnd value.
 
template<typename T , typename S >
sf::calculateOffset (T value, T min, T max, S len, bool clip)
 Calculates the offset for a given range and set point.
 
template<typename T >
sf::clip (const T value, const T lower_lim, const T upper_lim)
 Template function clipping the given value between an upper and lower limit.
 
template<typename T >
sf::random (T start, T stop)
 Generates random numbers within a specified integer range.
 
template<typename T >
sf::modulo (T k, T n)
 Modulo template function.
 
template<typename T >
sf::toAbs (T v)
 Gets the absolute value of a passed scalar value.
 
template<typename T >
sf::ipow (T base, int exponent)
 Fast integer power-of function.
 
template<typename T >
constexpr T sf::toRadians (T degrees)
 Converts degrees to radians.
 
template<typename T >
constexpr T sf::toDegrees (T radians)
 Converts radians to degrees.
 
template<typename T >
bool sf::isEqual (T a, T b, T epsilon=std::numeric_limits< T >::epsilon())
 Compares 2 floating point values of the same type with a given epsilon.
 
template<typename T >
bool sf::isZero (T value, T epsilon=std::numeric_limits< T >::epsilon())
 Check if the passed value is zero or near zero according the given epsilon.
 
template<typename T >
bool sf::isValidValue (T value)
 Check if the passed value is not NaN or infinity.
 
template<typename T , typename... Args>
size_t sf::maxArgumentIndex (T first, Args... args)
 Finds the index of the largest element passed as an argument.
 
template<typename T , typename... Args>
size_t sf::minArgumentIndex (T first, Args... args)
 Finds the index of the smallest element passed as an argument.
 
template<typename T , size_t N>
size_t sf::maxArrayIndex (const std::array< T, N > &arr)
 Finds the largest element index of the passed array.
 
template<typename T , size_t N>
size_t sf::minArrayIndex (const std::array< T, N > &arr)
 Finds the largest element index of the passed array.
 
_MISC_FUNC int sf::precision (double value)
 Returns the precision of the passed floating point value. This is the amount of characters after the point without the trailing zeros. When the value is 12300.00 the value returned is 3. When the value is 0.0123 the value returned is also 3.
 
_MISC_FUNC int sf::digits (double value)
 Returns the amount of digits which are significant for the value. When the value is 12300.00 the value returned is -2. When the value is 0.0123 the value returned is 4.
 
template<typename T >
std::pair< T, int > sf::getMantissaExponent (T value)
 Gets the mantissa and exponent part of a floating point value.
 
template<typename T >
int sf::magnitude (T value)
 Gets the order of magnitude of the passed floating point value. Examples: magnitude(0.001234) => -2 magnitude(0.123400) => 0 magnitude(12340.00) => 5.
 
_MISC_FUNC int sf::magnitudeObsolete (double value)
 Gets the order of magnitude of the passed double value. Examples: magnitude(0.001234) => -2 magnitude(0.123400) => 0 magnitude(12340.00) => 5.
 
_MISC_FUNC int sf::requiredDigits (double round_val, double min_val, double max_val)
 Gets the amount of required digits needed when drawing a scale.
 

Variables

template<typename T >
constexpr T sf::numbers::pi_v = static_cast<T>(3.141592653589793238462643383279502884L)