Utilities
Utilities header only library
glm_ext Namespace Reference

Extensions to the glm library. More...

Data Structures

class  TransMat
 Template wrapper for glm matrix holding matrix and its inverse. More...
 

Typedefs

using TransMat3 = TransMat< 3 >
 Wrapper glm::mat3 holding matrix and its inverse.
 
using TransMat4 = TransMat< 4 >
 Wrapper glm::mat4 holding matrix and its inverse.
 

Functions

template<int N, typename genType >
std::string to_string (const glm::vec< N, genType, glm::highp > &vec, const std::string &delim=", ")
 Converts the input vector into a string with predefined delimiter.
 
template<int N, int M, typename genType >
std::string to_string (const glm::mat< N, M, genType, glm::highp > &mat, const std::string &delim_col=", ", const std::string &delim_row="\)
 Converts matrix into a string using defined delimiters.
 
std::string to_string (const glm::quat &q, const std::string &delim=", ")
 Converts the input quaternion into a string with predefined delimiter.
 
template<int N, typename genType >
bool parse_string (const std::string &str, glm::vec< N, genType, glm::highp > &out_vec, const std::string &delim=", ")
 Parses a string to a glm vector using defined delimiters or fails.
 
template<int N, int M, typename genType >
bool parse_string (const std::string &str, glm::mat< N, M, genType, glm::highp > &out_mat, const std::string &delim_col=", ", const std::string &delim_row="\)
 Parses a string to a matrix using defined delimiters or fails.
 
bool parse_string (const std::string &str, glm::quat &out_quat, const std::string &delim=", ")
 Parses a string to a glm quaternion using defined delimiters or fails.
 
template<typename genType >
genType sqr (genType value)
 Returns square of a value or vector.
 
template<typename Type , glm::length_t N>
Type min (const glm::vec< N, Type > &vec)
 Returns minimal value component of a vector.
 
template<typename Type , glm::length_t N>
Type max (const glm::vec< N, Type > &vec)
 Returns maximal value component of a vector.
 
template<typename genType >
genType min (genType p1, genType p2, genType p3)
 Returns minimum of three values or individual vector components.
 
template<typename genType >
genType max (genType p1, genType p2, genType p3)
 Returns maximum of three values or individual vector components.
 
template<typename genType >
genType Clamp01 (genType x)
 Clamps a value or individual vector components to the range 0-1.
 
template<int N>
bool IsNormalized (const glm::vec< N, float > &vector)
 Returns true if vector is normalized in <0,1> interval.
 
template<typename T >
bool AreEqual (const T val1, const T val2, const T epsilon=std::numeric_limits< T >::epsilon())
 Returns true if two values are equal within defined epsilon threshold.
 
template<typename T , int N>
bool AreEqual (const glm::vec< N, T > &vec1, const glm::vec< N, T > &vec2, const T epsilon=std::numeric_limits< T >::epsilon())
 Returns true if all components of two vectors are equal within defined epsilon threshold.
 
bool AreEqual (const glm::quat &q1, const glm::quat &q2, const float epsilon=FLT_EPSILON)
 Returns true if two quaternions are equal within defined epsilon threshold.
 
template<typename T , int N, int M>
bool AreEqual (const glm::mat< N, M, T > &mat1, const glm::mat< N, M, T > &mat2, const T epsilon=std::numeric_limits< T >::epsilon())
 Returns true if all elements of two matrices are equal within defined epsilon threshold.
 
bool IsZero (const float val, const float epsilon=FLT_EPSILON)
 Returns true if a value is equal to zero within defined epsilon threshold.
 
template<typename T , typename... TS>
bool AllEqual (const float precision, const T a, const T b, const TS ... elements)
 Checks a variable number of elements for equality with a given precision. More...
 
template<typename T , typename... TS>
bool AllEqual (const float precision, const T a)
 Checks a variable number of elements for equality with a given precision. Boundary case for the variadic number of elements case.
 
template<int N, int M, typename genType >
bool IsAnyNan (const glm::mat< N, M, genType, glm::highp > &mat)
 Return whether any element in the matrix is NaN.
 
template<typename Type , glm::length_t N>
bool IsZero (const glm::vec< N, Type > &vec, const float epsilon=FLT_EPSILON)
 Returns true if all components of vector are equal to zero within defined epsilon threshold.
 
template<int N>
bool IsLess (const glm::vec< N, float > &vec1, const glm::vec< N, float > &vec2, const float epsilon=FLT_EPSILON)
 Returns true if all components of vec1 are less then vec2 within defined epsilon threshold.
 
bool IsLess (const float val1, const float val2, const float epsilon=FLT_EPSILON)
 Returns true if val1 is less then val2 within defined epsilon threshold.
 
template<int N>
bool IsLequal (const glm::vec< N, float > &vec1, const glm::vec< N, float > &vec2, const float epsilon=FLT_EPSILON)
 Returns true if all components of vec1 are less or equal then vec2 within defined epsilon threshold.
 
bool IsLequal (const float val1, const float val2, const float epsilon=FLT_EPSILON)
 Returns true if val1 is less or equal then val2 within defined epsilon threshold.
 
template<int N>
bool IsGreater (const glm::vec< N, float > &vec1, const glm::vec< N, float > &vec2, const float epsilon=FLT_EPSILON)
 Returns true if all components of vec1 are grater then vec2 within defined epsilon threshold.
 
bool IsGreater (const float val1, const float val2, const float epsilon=FLT_EPSILON)
 Returns true if val1 is greater then val2 within defined epsilon threshold.
 
template<int N>
bool IsGequal (const glm::vec< N, float > &vec1, const glm::vec< N, float > &vec2, const float epsilon=FLT_EPSILON)
 Returns true if all components of vec1 are grater or equal then vec2 within defined epsilon threshold.
 
bool IsGequal (const float val1, const float val2, const float epsilon=FLT_EPSILON)
 Returns true if val1 is greater or equal then val2 within defined epsilon threshold.
 
int doti (const glm::ivec2 &x, const glm::ivec2 &y)
 Dot product of two integer vectors.
 
float map (float val, float in_min, float in_max, float out_min, float out_max)
 Function that maps the input value in the input interval into an output value inside the output interval.
 
float Gaussian (float x, float mean, float sigma)
 Calculates function value f(x) of normal distribution function. More...
 
float Rand01 (int precision=1000)
 Returns random number in interval <0,1>, with specified precision (defaults to 3 digits).
 
float RandomInRange (float min, float max, int precision=1000)
 Returns random number in specified interval, with specified precision (defaults to 3 digits).
 
glm::vec3 RandomVec3 ()
 
glm::quat RandomQuat ()
 
glm::mat4 CreateProjectionMatrix (const glm::uvec2 &resolution, const float fx, const float fy, const float cx, const float cy, const float near_plane=0.01f, const float far_plane=1000.0f)
 
template<typename T >
bool IsInRange (T value, T min, T max)
 

Detailed Description

Extensions to the glm library.

Function Documentation

◆ AllEqual()

template<typename T , typename... TS>
bool glm_ext::AllEqual ( const float  precision,
const T  a,
const T  b,
const TS ...  elements 
)
inline

Checks a variable number of elements for equality with a given precision.

Note
Since the number of elements is variadic, the precision argument must be specified first.
Warning
Performs comparison on consecutive elements.
Here is the call graph for this function:

◆ Gaussian()

float glm_ext::Gaussian ( float  x,
float  mean,
float  sigma 
)
inline

Calculates function value f(x) of normal distribution function.

Parameters
xValue for which to calculate functional value.
meanMean value of normal distribution function.
sigmaStandard deviation of distribution. Note: interval <-3*sigma, 3*sigma> around mean value covers 99.72% of gauss distribution.
Here is the call graph for this function: