NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
math.hpp File Reference

Provides various math utility functions. More...

#include <algorithm>
#include <cassert>
#include <tuple>
#include <type_traits>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include "NNL/common/constant.hpp"
#include "NNL/common/contract.hpp"
#include "NNL/common/fixed_type.hpp"
#include "NNL/utility/trait.hpp"

Go to the source code of this file.

Namespaces

namespace  nnl
namespace  nnl::utl::math
 Provides various math utility functions.

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

Detailed Description

Provides various math utility functions.