NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
nnl::utl::math Namespace Reference

Provides various math utility functions. More...

Functions

bool IsNan (float value)
 Checks if a floating-point value is not a number.
template<typename TContainer>
bool IsNan (const TContainer &value)
 Checks if a container has any floating-point values that are not numbers.
bool IsFinite (float value)
 Checks if a floating-point value is finite.
template<typename TContainer>
bool IsFinite (const TContainer &container)
 Checks if all floating-point values in a container are finite.
glm::quat EulerToQuat (glm::vec3 euler)
 Converts Euler angles in degrees (Pitch X, Yaw Y, Roll Z) to a quaternion.
glm::vec3 QuatToEuler (glm::quat quat)
 Converts quaternion to Euler angles (Pitch X, Yaw Y, Roll Z)
std::tuple< glm::vec3, glm::quat, glm::vec3 > Decompose (const glm::mat4 &matrix)
 Decomposes a transformation matrix into scale, rotation, and translation.
glm::mat4 Compose (glm::vec3 scale, glm::quat rotation, glm::vec3 translation)
 Composes a transformation matrix from scale, rotation, and translation.
glm::mat4 InverseSafe (const glm::mat4 &m)
 Computes the inverse of a matrix safely.
glm::mat3 InverseSafe (const glm::mat3 &m)
 Computes the inverse of a matrix safely.
glm::mat4 Inverse (const glm::mat4 &m)
 Computes the inverse of a matrix.
glm::mat3 Inverse (const glm::mat3 &m)
 Computes the inverse of a matrix.
glm::vec3 NormalizeSafe (const glm::vec3 &vec)
 Normalizes a vector safely.
template<typename T>
constexpr T Sqr (T value)
 Calculates the square of a value.
template<typename T>
bool IsPow2 (T n)
 Checks whether a number can be expressed as an integer power of 2.
u32 RoundUpPow2 (u32 v)
 Rounds up the number to the next power of 2.
u32 RoundDownPow2 (u32 v)
 Rounds down to the previous power of 2.
template<typename T>
RoundNum (T number, std::size_t multiple)
 Rounds number up to the nearest multiple.
template<typename T, std::size_t num_int = 0>
constexpr T FloatToFixed (f32 value)
 Converts a float value to a fixed point value.
template<typename T, std::size_t num_int = 0>
constexpr f32 FixedToFloat (T value)
 Converts a fixed-point value to a float value.
bool IsApproxEqual (float a, float b, float range=NNL_EPSILON)
 Checks if floating-point numbers are approximately equal.
template<typename TContainer>
bool IsApproxEqual (TContainer a, TContainer b, float range=NNL_EPSILON)
 Checks if two vectors or matrices are approximately equal.

Detailed Description

Provides various math utility functions.