|
NSUNI/NSLAR Library a250670
|
Provides various math utility functions. More...
Functions | |
| bool | nnl::utl::math::IsNan (float value) |
| Checks if a floating-point value is not a number. | |
| template<typename TContainer> | |
| bool | nnl::utl::math::IsNan (const TContainer &value) |
| Checks if a container has any floating-point values that are not numbers. | |
| bool | nnl::utl::math::IsFinite (float value) |
| Checks if a floating-point value is finite. | |
| template<typename TContainer> | |
| bool | nnl::utl::math::IsFinite (const TContainer &container) |
| Checks if all floating-point values in a container are finite. | |
| glm::quat | nnl::utl::math::EulerToQuat (glm::vec3 euler) |
| Converts Euler angles in degrees (Pitch X, Yaw Y, Roll Z) to a quaternion. | |
| glm::vec3 | nnl::utl::math::QuatToEuler (glm::quat quat) |
| Converts quaternion to Euler angles (Pitch X, Yaw Y, Roll Z) | |
| std::tuple< glm::vec3, glm::quat, glm::vec3 > | nnl::utl::math::Decompose (const glm::mat4 &matrix) |
| Decomposes a transformation matrix into scale, rotation, and translation. | |
| glm::mat4 | nnl::utl::math::Compose (glm::vec3 scale, glm::quat rotation, glm::vec3 translation) |
| Composes a transformation matrix from scale, rotation, and translation. | |
| glm::mat4 | nnl::utl::math::InverseSafe (const glm::mat4 &m) |
| Computes the inverse of a matrix safely. | |
| glm::mat3 | nnl::utl::math::InverseSafe (const glm::mat3 &m) |
| Computes the inverse of a matrix safely. | |
| glm::mat4 | nnl::utl::math::Inverse (const glm::mat4 &m) |
| Computes the inverse of a matrix. | |
| glm::mat3 | nnl::utl::math::Inverse (const glm::mat3 &m) |
| Computes the inverse of a matrix. | |
| glm::vec3 | nnl::utl::math::NormalizeSafe (const glm::vec3 &vec) |
| Normalizes a vector safely. | |
| template<typename T> | |
| constexpr T | nnl::utl::math::Sqr (T value) |
| Calculates the square of a value. | |
| template<typename T> | |
| bool | nnl::utl::math::IsPow2 (T n) |
| Checks whether a number can be expressed as an integer power of 2. | |
| u32 | nnl::utl::math::RoundUpPow2 (u32 v) |
| Rounds up the number to the next power of 2. | |
| u32 | nnl::utl::math::RoundDownPow2 (u32 v) |
| Rounds down to the previous power of 2. | |
| template<typename T> | |
| T | nnl::utl::math::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 | nnl::utl::math::FloatToFixed (f32 value) |
| Converts a float value to a fixed point value. | |
| template<typename T, std::size_t num_int = 0> | |
| constexpr f32 | nnl::utl::math::FixedToFloat (T value) |
| Converts a fixed-point value to a float value. | |
| bool | nnl::utl::math::IsApproxEqual (float a, float b, float range=NNL_EPSILON) |
| Checks if floating-point numbers are approximately equal. | |
| template<typename TContainer> | |
| bool | nnl::utl::math::IsApproxEqual (TContainer a, TContainer b, float range=NNL_EPSILON) |
| Checks if two vectors or matrices are approximately equal. | |
Provides various math utility functions.
| glm::mat4 nnl::utl::math::Compose | ( | glm::vec3 | scale, |
| glm::quat | rotation, | ||
| glm::vec3 | translation ) |
Composes a transformation matrix from scale, rotation, and translation.
| scale | |
| rotation | |
| translation |
| std::tuple< glm::vec3, glm::quat, glm::vec3 > nnl::utl::math::Decompose | ( | const glm::mat4 & | matrix | ) |
Decomposes a transformation matrix into scale, rotation, and translation.
| matrix | The 4x4 transformation matrix to decompose |
| glm::quat nnl::utl::math::EulerToQuat | ( | glm::vec3 | euler | ) |
Converts Euler angles in degrees (Pitch X, Yaw Y, Roll Z) to a quaternion.
| euler | The angles to convert |
|
constexpr |
Converts a fixed-point value to a float value.
| T | Integral type |
| num_int | Num of bits for the integer part |
| value | Integer value to convert |
|
constexpr |
Converts a float value to a fixed point value.
| T | Integral type |
| num_int | Num of bits for the integer part |
| value | Float value to convert |
| glm::mat3 nnl::utl::math::Inverse | ( | const glm::mat3 & | m | ) |
Computes the inverse of a matrix.
This function takes a matrix and returns its inverse. If the matrix is not invertible, the result is undefined.
| m | The matrix to be inverted. |
| glm::mat4 nnl::utl::math::Inverse | ( | const glm::mat4 & | m | ) |
Computes the inverse of a matrix.
This function takes a matrix and returns its inverse. If the matrix is not invertible, the result is undefined.
| m | The matrix to be inverted. |
| glm::mat3 nnl::utl::math::InverseSafe | ( | const glm::mat3 & | m | ) |
Computes the inverse of a matrix safely.
This function takes a matrix and returns its inverse. If the matrix is not invertible, a small value is added to its diagonal elements. If the adjusted matrix is still not invertible, the function will return the identity matrix.
| m | The matrix to be inverted. |
| glm::mat4 nnl::utl::math::InverseSafe | ( | const glm::mat4 & | m | ) |
Computes the inverse of a matrix safely.
This function takes a matrix and returns its inverse. If the matrix is not invertible, a small value is added to its diagonal elements. If the adjusted matrix is still not invertible, the function will return the identity matrix.
| m | The matrix to be inverted. |
|
inline |
Checks if floating-point numbers are approximately equal.
| a | First float |
| b | Second float |
| range | Tolerance range |
| bool nnl::utl::math::IsApproxEqual | ( | TContainer | a, |
| TContainer | b, | ||
| float | range = NNL_EPSILON ) |
Checks if two vectors or matrices are approximately equal.
| T | Container type |
| a | First value |
| b | Second value |
| range | Tolerance range per element |
| bool nnl::utl::math::IsFinite | ( | const TContainer & | container | ) |
Checks if all floating-point values in a container are finite.
| TContainer | Container type |
| container | The container to check. |
|
inline |
Checks if a floating-point value is finite.
| value | The value to check. |
| bool nnl::utl::math::IsNan | ( | const TContainer & | value | ) |
Checks if a container has any floating-point values that are not numbers.
| TContainer | Container type |
| value | The container to check. |
|
inline |
Checks if a floating-point value is not a number.
| value | The value to check. |
| bool nnl::utl::math::IsPow2 | ( | T | n | ) |
Checks whether a number can be expressed as an integer power of 2.
| T | Integral type |
| n | The number to check |
| glm::vec3 nnl::utl::math::NormalizeSafe | ( | const glm::vec3 & | vec | ) |
Normalizes a vector safely.
Returns a unit vector pointing in the same direction as the input. If the input vector has a length of zero (or is near-zero), it returns a default vector.
| vec | The vector to be normalized. |
| glm::vec3 nnl::utl::math::QuatToEuler | ( | glm::quat | quat | ) |
Converts quaternion to Euler angles (Pitch X, Yaw Y, Roll Z)
| quat | The quaternion to convert |
Rounds down to the previous power of 2.
| v | 32-bit unsigned integer to round |
| T nnl::utl::math::RoundNum | ( | T | number, |
| std::size_t | multiple ) |
Rounds number up to the nearest multiple.
| T | Integral type |
| number | Number to round |
| multiple | Rounding multiple |
Rounds up the number to the next power of 2.
| v | 32-bit unsigned integer to round |
|
inlineconstexpr |
Calculates the square of a value.
| T | Numeric type |
| value | The value to square |