# namespace glm_ext

## Overview

Extensions to the glm library. More…

    namespace glm_ext {

    // typedefs

    typedef TransMat<3> TransMat3;
    typedef TransMat<4> TransMat4;

    // classes

    template <int N>
    class TransMat;

    // global functions

    template <int N, typename genType>
    std::string to_string(const glm::vec<N, genType, glm::highp>& vec, const std::string& delim = ", ");

    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 = ", ");

    std::string to_string(const glm::quat& q, const std::string& delim = ", ");

    template <int N, typename genType>
    bool parse_string(const std::string& str, glm::vec<N, genType, glm::highp>& out_vec, const std::string& delim = ", ");

    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 = ", ");

    bool parse_string(const std::string& str, glm::quat& out_quat, const std::string& delim = ", ");

    template <typename genType>
    genType sqr(genType value);

    template <typename Type, glm::length_t N>
    Type min(const glm::vec<N, Type>& vec);

    template <typename Type, glm::length_t N>
    Type max(const glm::vec<N, Type>& vec);

    template <typename genType>
    genType min(genType p1, genType p2, genType p3);

    template <typename genType>
    genType max(genType p1, genType p2, genType p3);

    template <typename genType>
    genType Clamp01(genType x);

    template <int N>
    bool IsNormalized(const glm::vec<N, float>& vector);

    template <typename T>
    bool AreEqual(const T val1, const T val2, const T epsilon = std::numeric_limits<T>::epsilon());

    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());

    bool AreEqual(const glm::quat& q1, const glm::quat& q2, const float epsilon = FLT_EPSILON);

    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());

    bool IsZero(const float val, const float epsilon = FLT_EPSILON);

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

    template <typename T, typename... TS>
    bool AllEqual(const float precision, const T a);

    template <int N, int M, typename genType>
    bool IsAnyNan(const glm::mat<N, M, genType, glm::highp>& mat);

    template <typename Type, glm::length_t N>
    bool IsZero(const glm::vec<N, Type>& vec, const float epsilon = FLT_EPSILON);

    template <int N>
    bool IsLess(const glm::vec<N, float>& vec1, const glm::vec<N, float>& vec2, const float epsilon = FLT_EPSILON);

    bool IsLess(const float val1, const float val2, const float epsilon = FLT_EPSILON);

    template <int N>
    bool IsLequal(const glm::vec<N, float>& vec1, const glm::vec<N, float>& vec2, const float epsilon = FLT_EPSILON);

    bool IsLequal(const float val1, const float val2, const float epsilon = FLT_EPSILON);

    template <int N>
    bool IsGreater(const glm::vec<N, float>& vec1, const glm::vec<N, float>& vec2, const float epsilon = FLT_EPSILON);

    bool IsGreater(const float val1, const float val2, const float epsilon = FLT_EPSILON);

    template <int N>
    bool IsGequal(const glm::vec<N, float>& vec1, const glm::vec<N, float>& vec2, const float epsilon = FLT_EPSILON);

    bool IsGequal(const float val1, const float val2, const float epsilon = FLT_EPSILON);
    int doti(const glm::ivec2& x, const glm::ivec2& y);
    float map(float val, float in_min, float in_max, float out_min, float out_max);
    float Gaussian(float x, float mean, float sigma);
    float Rand01(int precision = 1000);
    float RandomInRange(float min, float max, int precision = 1000);
    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);

    } // namespace glm_ext

## Detailed Documentation

Extensions to the glm library.

### Typedefs

    typedef TransMat<3> TransMat3

Wrapper glm::mat3 holding matrix and its inverse.

    typedef TransMat<4> TransMat4

Wrapper glm::mat4 holding matrix and its inverse.

### Global 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 = ", ")

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 = ", ")

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.

Since the number of elements is variadic, the precision argument must be specified first.

Performs comparison on consecutive elements.

    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.

Parameters:

x | Value for which to calculate functional value.
mean | Mean value of normal distribution function.
sigma | Standard deviation of distribution. Note: interval <-3*sigma, 3*sigma> around mean value covers 99.72% of gauss distribution.

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