Raven Engine v0.1
Loading...
Searching...
No Matches
BasicMath.h File Reference

Core low-level math utility functions for Crux engine. More...

#include "Crux/Utils/Constants.h"
#include <bit>
#include <immintrin.h>

Namespaces

namespace  Crux

Functions

template<typename T>
constexpr T Crux::Lerp (T a, T b, float t)
 Linear interpolation between a and b by factor t.
template<typename T>
constexpr T Crux::Min (T a, T b)
 Return the minimum of two values.
template<typename T>
constexpr T Crux::Max (T a, T b)
 Return the maximum of two values.
template<typename T>
constexpr T Crux::Clamp (T value, T min, T max)
 Clamp a value between a minimum and maximum.
template<typename T>
constexpr T Crux::Saturate (T value)
 Clamp a value to the [0,1] range.
template<typename T>
constexpr T Crux::Sign (T value)
 Signum function: returns -1, 0, or +1.
template<typename T>
constexpr T Crux::Abs (T value)
 Absolute value.
template<typename T>
constexpr T Crux::Floor (T value)
 Floor function for floating-point values.
template<typename T>
constexpr T Crux::Ceil (T value)
 Ceiling function for floating-point values.
template<typename T>
constexpr T Crux::Fract (T value)
 Fractional part of a value.
template<typename T>
constexpr T Crux::Square (T value)
 Square of a value.
template<typename T>
constexpr T Crux::Cube (T value)
 Cube of a value.
constexpr float Crux::Smoothstep (float edge0, float edge1, float x)
 Smoothstep interpolation between edge0 and edge1.
constexpr float Crux::CTInverseSqrt (float x)
 Fast compile-time inverse square root (single Newton step).
constexpr float Crux::CTSqrt (const float x)
 Fast compile-time square root using bit manipulation.
float Crux::InverseSqrt (const float x)
 Inverse square root using hardware rsqrt.
float Crux::Sqrt (const float x)
 Standard square root using hardware sqrt.

Detailed Description

Core low-level math utility functions for Crux engine.

Provides basic arithmetic operations, interpolation, clamping, and fast approximations for common mathematical functions. All functions are constexpr/inline where possible to enable compile-time evaluation and aggressive inlining.

Author
Philip