CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Math.hpp File Reference
#include "FloatingPoint.hpp"
#include "Matrix.hpp"
#include "Quaternion.hpp"
#include "Vector.hpp"
#include "CeresEngine/Foundation/Container/Array.hpp"
#include <glm/common.hpp>
#include <glm/exponential.hpp>
#include <glm/geometric.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/trigonometric.hpp>
#include <glm/vector_relational.hpp>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/matrix_decompose.hpp>
#include <glm/gtx/matrix_major_storage.hpp>
#include <glm/gtx/matrix_transform_2d.hpp>
#include <glm/gtx/norm.hpp>
#include <glm/gtx/normal.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtx/string_cast.hpp>
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Classes

struct  Math::detail::bezierDerivativeImpl< O, D, VecT, T >
 
struct  Math::detail::bezierDerivativeImpl< 0, D, VecT, T >
 
struct  Math::detail::bezierDerivativeImpl< 0, 1, VecT, T >
 
struct  Math::detail::bezierDerivativeImpl< O, 1, VecT, T >
 

Namespaces

namespace  Math
 
namespace  Math::detail
 
namespace  Math::Constant
 

Macros

#define GLM_ENABLE_EXPERIMENTAL
 
#define IMPORT_FROM_GLM(Symbol)
 
#define IMPORT_GLM_CONSTANT_NAMED(Symbol, Name)   template<typename T> inline const T Name = glm::Symbol<T>()
 
#define IMPORT_GLM_CONSTANT(Symbol)   IMPORT_GLM_CONSTANT_NAMED(Symbol, Symbol)
 

Functions

template<typename T >
TMatrix4< T > constexpr Math::flipProjectionY (TMatrix4< T > proj) noexcept
 
template<typename T >
constexpr TMatrix4< T > Math::frustum (T left, T right, T bottom, T top, T zNear, T zFar) noexcept
 Creates a frustum matrix with default handedness, using the default handedness and default near and far clip planes definition.
 
template<typename T >
constexpr TMatrix4< T > Math::perspective (T fovy, T aspect, T zNear, T zFar) noexcept
 Creates a matrix for a symetric perspective-view frustum based on the default handedness and default near and far clip planes definition.
 
template<typename T >
constexpr TMatrix4< T > Math::perspectiveFov (T fov, T width, T height, T zNear, T zFar) noexcept
 Builds a perspective projection matrix based on a field of view and the default handedness and default near and far clip planes definition.
 
template<typename T >
constexpr TMatrix4< T > Math::infinitePerspective (T fovy, T aspect, T zNear) noexcept
 Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
 
template<typename T >
constexpr TMatrix4< T > Math::tweakedInfinitePerspective (T fovy, T aspect, T zNear) noexcept
 Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
 
template<typename T >
constexpr TMatrix4< T > Math::tweakedInfinitePerspective (T fovy, T aspect, T zNear, T ep) noexcept
 Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
 
template<typename T >
constexpr TMatrix4< T > Math::ortho (T left, T right, T bottom, T top, T zNear, T zFar)
 Creates a matrix for projecting two-dimensional coordinates onto the screen.
 
template<typename T >
double Math::smoothStep (T val1, T val2, T t)
 Performs smooth Hermite interpolation between values.
 
template<typename T >
Math::quintic (T val)
 Performs quintic interpolation where val is the value to map onto a quintic S-curve.
 
template<typename T , typename U >
auto Math::cubic (T val1, T val2, T val3, T val4, U f)
 Performs cubic interpolation between two values bound between two other values where f is the alpha value.
 
template<typename T , glm::length_t D>
bool Math::approxEquals (const TVector< D, T > &a, const TVector< D, T > &b, T tolerance=std::numeric_limits< T >::epsilon())
 Compare two vectors, using tolerance for inaccuracies.
 
template<typename T , glm::length_t D>
bool Math::approxEquals (const TVector< D, T > &a, T b, T tolerance=std::numeric_limits< T >::epsilon())
 Compare two vectors, using tolerance for inaccuracies.
 
template<typename T >
bool Math::approxEquals (const TQuaternion< T > &a, const TQuaternion< T > &b, T tolerance=std::numeric_limits< T >::epsilon())
 Compare two quaternions, using tolerance for inaccuracies.
 
template<typename T >
Math::lerp (T t, T min, T max)
 Linearly interpolates between the two values using t.
 
template<typename T >
Math::invLerp (T val, T min, T max)
 Determines the position of a value between two other values.
 
template<typename A , typename B >
std::common_type_t< A, B > Math::gcd (const A &a, const B &b)
 Return the greater common divisor between two values.
 
template<typename A , typename B >
std::common_type_t< A, B > Math::lcm (const A &a, const B &b)
 Return the least common multiple between two values.
 
template<typename T >
int Math::solveLinear (T A, T B, T *roots)
 Solves the linear equation with the parameters A, B.
 
template<typename T >
int Math::solveQuadratic (T A, T B, T C, T *roots)
 Solves the quadratic equation with the parameters A, B, C.
 
template<typename T >
int Math::solveCubic (T A, T B, T C, T D, T *roots)
 Solves the cubic equation with the parameters A, B, C, D.
 
template<typename T >
int Math::solveQuartic (T A, T B, T C, T D, T E, T *roots)
 Solves the quartic equation with the parameters A, B, C, D, E.
 
template<class T >
Math::cubicHermite (const double t, const T &pointA, const T &pointB, const T &tangentA, const T &tangentB)
 Evaluates a cubic Hermite curve at a specific point.
 
template<class T >
Math::cubicHermiteD1 (const double t, const T &pointA, const T &pointB, const T &tangentA, const T &tangentB)
 Evaluates the first derivative of a cubic Hermite curve at a specific point.
 
template<class T >
Array< T, 4 > Math::cubicHermiteCoefficients (const T &pointA, const T &pointB, const T &tangentA, const T &tangentB)
 Calculates coefficients needed for evaluating a cubic curve in Hermite form.
 
template<class T , typename L >
Array< T, 4 > Math::cubicHermiteCoefficients (const T &pointA, const T &pointB, const T &tangentA, const T &tangentB, L length)
 Calculates coefficients needed for evaluating a cubic curve in Hermite form.
 
template<typename T , typename Integrand >
Math::rombergIntegration (T a, T b, int order, Integrand &&integrand)
 Calculates the Romberg Integration.
 
template<typename T , typename Integrand >
Math::gaussianQuadrature (T a, T b, T *roots, T *coefficients, Integrand &&integrand)
 Calculates the Gaussian Quadrature.
 
template<typename T >
Math::haltonSequence (int index, int base)
 Generates numbers in a deterministic sequence suitable for Monte Carlo algorithms.
 
template<typename T >
Math::angle (const TVector2< T > &v1, const TVector2< T > &v2)
 
template<typename T >
Math::angle (const TVector3< T > &v1, const TVector3< T > &v2)
 
template<typename T >
TVector2< T > Math::cross (const TVector2< T > &v)
 
template<typename T >
TVector3< T > Math::transform (const TQuaternion< T > &q, const TVector3< T > &v)
 
template<typename T >
TQuaternion< T > Math::qrotate (const T &angle, const TVector3< T > &axis)
 
template<typename T >
TVector3< T > Math::normal (const TVector3< T > &p1, const TVector3< T > &p2, const TVector3< T > &p3)
 
template<typename T , typename TI , typename TS >
TVector3< T > Math::project (const TVector3< T > &v, const TMatrix4< T > &modelViewProj, const TVector2< TI > &viewportOrigin, const TVector2< TS > &viewportSize)
 
template<typename T >
TMatrix4< T > Math::ortho2D (const T &left, const T &right, const T &bottom, const T &top)
 
template<typename T >
TVector3< T > Math::slerp (const TVector3< T > &v1, const TVector3< T > &v2, const T &a)
 
template<typename T >
TMatrix4< T > Math::rotate (const TVector3< T > &angle)
 
template<typename T >
TMatrix3< T > Math::rotate (const T &angle)
 
template<typename T >
TVector2< T > Math::transform (const TMatrix3< T > &m, const TVector2< T > &v)
 
template<typename VecT , typename T >
VecT Math::detail::bezierImpl (const VecT *p, const int n, T t1, T t2, int stride=1)
 
template<int D, typename T >
TVector2< T > Math::bezier (const TVector2< T >(&p)[D], T t)
 
template<int D, typename T >
TVector3< T > Math::bezier (const TVector3< T >(&p)[D], T t)
 
template<int D0, int D1, typename T >
TVector3< T > Math::bezier2 (const TVector3< T >(&p)[D1][D0], const TVector2< T > &t)
 
template<int O, int D, typename T >
TVector2< T > Math::bezierDerivative (const TVector2< T >(&p)[D], T t)
 
template<int O, int D, typename T >
TVector3< T > Math::bezierDerivative (const TVector3< T >(&p)[D], T t)
 
template<int O, int D0, int D1, typename T >
TMatrix2x3< T > Math::bezier2Jacobian (const TVector3< T >(&p)[D1][D0], const TVector2< T > &t)
 

Variables

template<typename T >
const T Math::Constant::epsilon = glm:: epsilon <T>()
 Return the epsilon constant for floating point types.
 
template<typename T >
const T Math::Constant::_0 = glm:: zero <T>()
 Return 0.
 
template<typename T >
const T Math::Constant::_1 = glm:: one <T>()
 Return 1.
 
template<typename T >
const T Math::Constant::pi = glm:: pi <T>()
 Return the pi constant.
 
template<typename T >
const T Math::Constant::_2pi = glm:: two_pi <T>()
 Return pi///2.
 
template<typename T >
const T Math::Constant::sqrtPi = glm:: root_pi <T>()
 Return square root of pi.
 
template<typename T >
const T Math::Constant::pi_2 = glm:: half_pi <T>()
 Return pi / 2.
 
template<typename T >
const T Math::Constant::_3pi_2 = glm:: three_over_two_pi <T>()
 Return pi / 2///3.
 
template<typename T >
const T Math::Constant::pi_4 = glm:: quarter_pi <T>()
 Return pi / 4.
 
template<typename T >
const T Math::Constant::_1_pi = glm:: one_over_pi <T>()
 Return 1 / pi.
 
template<typename T >
const T Math::Constant::_1_2pi = glm:: one_over_two_pi <T>()
 Return 1 / (pi///2).
 
template<typename T >
const T Math::Constant::_2_pi = glm:: two_over_pi <T>()
 Return 2 / pi.
 
template<typename T >
const T Math::Constant::_4_pi = glm:: four_over_pi <T>()
 Return 4 / pi.
 
template<typename T >
const T Math::Constant::_2_sqrtpi = glm:: two_over_root_pi <T>()
 Return 2 / sqrt(pi).
 
template<typename T >
const T Math::Constant::_1_sqrt2 = glm:: one_over_root_two <T>()
 Return 1 / sqrt(2).
 
template<typename T >
const T Math::Constant::sqrt_pi_2 = glm:: root_half_pi <T>()
 Return sqrt(pi / 2).
 
template<typename T >
const T Math::Constant::sqrt_2pi = glm:: root_two_pi <T>()
 Return sqrt(2///pi).
 
template<typename T >
const T Math::Constant::e = glm:: e <T>()
 Return e constant.
 
template<typename T >
const T Math::Constant::euler = glm:: euler <T>()
 Return Euler's constant.
 
template<typename T >
const T Math::Constant::sqrt2 = glm:: root_two <T>()
 Return sqrt(2).
 
template<typename T >
const T Math::Constant::sqrt3 = glm:: root_three <T>()
 Return sqrt(3).
 
template<typename T >
const T Math::Constant::sqrt5 = glm:: root_five <T>()
 Return sqrt(5).
 
template<typename T >
const T Math::Constant::goldenRatio = glm:: golden_ratio <T>()
 Return the golden ratio constant.
 

Macro Definition Documentation

◆ GLM_ENABLE_EXPERIMENTAL

#define GLM_ENABLE_EXPERIMENTAL

◆ IMPORT_FROM_GLM

#define IMPORT_FROM_GLM (   Symbol)
Value:
namespace CeresEngine::inline Math { \
using glm::Symbol; \
}
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Angle.hpp:20

◆ IMPORT_GLM_CONSTANT

#define IMPORT_GLM_CONSTANT (   Symbol)    IMPORT_GLM_CONSTANT_NAMED(Symbol, Symbol)

◆ IMPORT_GLM_CONSTANT_NAMED

#define IMPORT_GLM_CONSTANT_NAMED (   Symbol,
  Name 
)    template<typename T> inline const T Name = glm::Symbol<T>()