OGLplus  (0.59.0) a C++ wrapper for rendering APIs

Math utilities

Classes

class  eagine::math::unit_spherical_coordinate< T, V >
 Class representing unit spherical coordinate. More...
 
class  eagine::math::bezier_curves< Type, Parameter, Order >
 A sequence of Bezier curves, possibly connected at end points. More...
 
class  eagine::math::cubic_bezier_loop< Type, Parameter >
 A closed smooth cubic Bezier spline passing through all input points. More...
 
struct  eagine::math::bezier_t< Type, Parameter, N >
 Helper class for bezier curve segment calculations. More...
 
struct  eagine::math::matrix< T, C, R, RM, V >
 Basic RxC matrix implementation template. More...
 
struct  eagine::math::is_row_major< matrix< T, C, R, RM, V > >
 Class testing if a matrix type is row-major. More...
 
struct  eagine::math::reordered_matrix< matrix< T, C, R, RM, V > >
 Implementation of reordered_matrix_t. More...
 
struct  eagine::math::is_matrix_constructor< X >
 Indicates if the specified type X is a matrix constructor. More...
 
struct  eagine::math::constructed_matrix< X >
 Gets the constructed matrix type for a matrix constructor type. More...
 
class  eagine::math::convertible_matrix_constructor< MC >
 Helper class used in matrix constructor implementation. More...
 
class  eagine::math::identity< matrix< T, R, C, RM, V > >
 Identity matrix constructor. More...
 
class  eagine::math::looking_at_y_up< matrix< T, 4, 4, RM, V > >
 Implements constructor of look-at matrix used for camera transformations. More...
 
class  eagine::math::orbiting_y_up< matrix< T, 4, 4, RM, V > >
 Implements constructor of orbiting matrix used for camera transformations. More...
 
class  eagine::math::ortho< matrix< T, 4, 4, RM, V > >
 Implements constructor of orthographic projection matrix. More...
 
class  eagine::math::perspective< matrix< T, 4, 4, RM, V > >
 Implements constructor of perspective projection matrix. More...
 
class  eagine::math::reflection_I< matrix< T, 4, 4, RM, V >, I >
 Implements constructor of reflection transformation matrix. More...
 
class  eagine::math::rotation_I< matrix< T, 4, 4, RM, V >, I >
 Implements constructor of rotation transformation matrix. More...
 
class  eagine::math::scale< matrix< T, 4, 4, RM, V > >
 Implements constructor of scale transformation matrix. More...
 
class  eagine::math::uniform_scale< matrix< T, 4, 4, RM, V > >
 Implements constructor of uniform scale transformation matrix. More...
 
class  eagine::math::translation< matrix< T, 4, 4, RM, V > >
 Implements constructor of translation transformation matrix. More...
 
class  eagine::math::basic_line< T, N, V >
 Basic template for lines in N-dimensional space. More...
 
class  eagine::math::basic_triangle< T, N, V >
 Basic template for triangles in N-dimensional space. More...
 
class  eagine::math::basic_sphere< T, N, V >
 Basic template for spheres in N-dimensional space. More...
 
struct  eagine::math::scalar< T, N, V >
 Basic scalar implementation template. More...
 
class  eagine::math::sign< T >
 Class representing a positive or negative numeric sign. More...
 
struct  eagine::math::tmat< T, C, R, RM, V >
 Generic template for RxC dimensional matrices. More...
 
struct  eagine::math::tvec< T, N, V >
 Generic template for N-dimensional vectors. More...
 
struct  eagine::math::vector< T, N, V >
 Basic N-dimensional vector implementation template. More...
 

Typedefs

template<typename X >
using eagine::math::reordered_matrix_t = typename reordered_matrix< X >::type
 Trait returns a reordered (switch row/column-major) type for a matrix type.
 
template<typename X >
using eagine::math::constructed_matrix_t = typename constructed_matrix< X >::type
 Trait returning the matrix type constructed by constructor type X.
 
template<typename T , bool V>
using eagine::math::matrix_looking_at_y_up = convertible_matrix_constructor< looking_at_y_up< matrix< T, 4, 4, true, V > >>
 Alias for constructor of look-at matrix used for camera transformations.
 
template<typename T , bool V>
using eagine::math::matrix_orbiting_y_up = convertible_matrix_constructor< orbiting_y_up< matrix< T, 4, 4, true, V > >>
 Alias for constructor of orbiting matrix used for camera transformations.
 
template<typename T , bool V>
using eagine::math::matrix_ortho = convertible_matrix_constructor< ortho< matrix< T, 4, 4, true, V > >>
 Alias for constructor of orthographic projection matrix.
 
template<typename T , bool V>
using eagine::math::matrix_perspective = convertible_matrix_constructor< perspective< matrix< T, 4, 4, true, V > >>
 Alias for constructor of perspective projection matrix.
 
template<typename M >
using eagine::math::reflection_x = reflection_I< M, 0 >
 Alias for implementation of constructor of reflection along x-axis matrix.
 
template<typename M >
using eagine::math::reflection_y = reflection_I< M, 1 >
 Alias for implementation of constructor of reflection along y-axis matrix.
 
template<typename M >
using eagine::math::reflection_z = reflection_I< M, 2 >
 Alias for implementation of constructor of reflection along z-axis matrix.
 
template<typename T , bool V>
using eagine::math::matrix_reflection_x = convertible_matrix_constructor< reflection_x< matrix< T, 4, 4, true, V > >>
 Alias for constructor of reflection along x-axis transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_reflection_y = convertible_matrix_constructor< reflection_y< matrix< T, 4, 4, true, V > >>
 Alias for constructor of reflection along y-axis transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_reflection_z = convertible_matrix_constructor< reflection_z< matrix< T, 4, 4, true, V > >>
 Alias for constructor of reflection along z-axis transformation matrix. More...
 
template<typename M >
using eagine::math::rotation_x = rotation_I< M, 0 >
 Alias for implementation of constructor of rotation along x-axis matrix.
 
template<typename M >
using eagine::math::rotation_y = rotation_I< M, 1 >
 Alias for implementation of constructor of rotation along y-axis matrix.
 
template<typename M >
using eagine::math::rotation_z = rotation_I< M, 2 >
 Alias for implementation of constructor of rotation along z-axis matrix.
 
template<typename T , bool V>
using eagine::math::matrix_rotation_x = convertible_matrix_constructor< rotation_x< matrix< T, 4, 4, true, V > >>
 Alias for constructor of rotation along x-axis transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_rotation_y = convertible_matrix_constructor< rotation_y< matrix< T, 4, 4, true, V > >>
 Alias for constructor of rotation along y-axis transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_rotation_z = convertible_matrix_constructor< rotation_z< matrix< T, 4, 4, true, V > >>
 Alias for constructor of rotation along z-axis transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_scale = convertible_matrix_constructor< scale< matrix< T, 4, 4, true, V > >>
 Alias for constructor of scale transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_uniform_scale = convertible_matrix_constructor< uniform_scale< matrix< T, 4, 4, true, V > >>
 Alias for constructor of uniform scale transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::matrix_translation = convertible_matrix_constructor< translation< matrix< T, 4, 4, true, V > >>
 Alias for constructor of uniform translation transformation matrix. More...
 
template<typename T , bool V>
using eagine::math::line = basic_line< T, 3, V >
 Alias for lines in 3D space.
 
template<typename T , bool V>
using eagine::math::triangle = basic_triangle< T, 3, V >
 Alias for triangles in 3D space.
 
template<typename T , bool V>
using eagine::math::sphere = basic_sphere< T, 3, V >
 Alias for spheres in 3D space.
 

Functions

template<typename T , bool V>
auto eagine::math::to_cartesian (unit_spherical_coordinate< T, V > c) noexcept -> vector< T, 3, V >
 Converts unit spherical coordinate to cartesian vector.
 
template<typename T , bool V>
auto eagine::math::to_unit_spherical (vector< T, 3, V > v) noexcept -> unit_spherical_coordinate< T, V >
 Converts cartesian vector to unit spherical coordinate.
 
template<typename T >
static constexpr auto eagine::math::is_positive_power_of_2 (T value) noexcept -> std::enable_if_t< std::is_integral_v< T >, bool >
 Indicates if value is a positive integral power of two.
 
template<typename T >
static constexpr auto eagine::math::greatest_common_divisor (T l, T r) noexcept -> std::enable_if_t< std::is_integral_v< T >, T >
 Returns the greates common divisor of arguments l and r.
 
template<typename T >
static constexpr auto eagine::math::signum (T x) noexcept
 Returns 1 if x is non-negative, returns -1 otherwise.
 
template<typename T >
static constexpr auto eagine::math::minimum (T a, T b) noexcept
 Returns the minimum value of a and b.
 
template<typename T , typename... P>
static constexpr auto eagine::math::minimum (T a, T b, T c, P... d) noexcept
 Returns the minimum value from multiple arguments.
 
template<typename T >
static constexpr auto eagine::math::maximum (T a, T b) noexcept
 Returns the maximum value of a and b.
 
template<typename T , typename... P>
static constexpr auto eagine::math::maximum (T a, T b, T c, P... d) noexcept
 Returns the maximum value from multiple arguments.
 
template<typename T >
static constexpr auto eagine::math::ratio (T a, T b) noexcept -> optionally_valid< T >
 Returns a divided by b if b is not zero.
 
template<typename T >
static constexpr auto eagine::math::reciprocal (T x) noexcept -> optionally_valid< T >
 Returns the reciprocal of x if x is not zero.
 
template<typename T , typename Min , typename Max >
static constexpr auto eagine::math::clamp (T x, Min min, Max max) noexcept
 Clamps x to be between min and max.
 
template<typename T , typename S , typename E >
static constexpr auto eagine::math::ramp (T x, S start, E end) noexcept
 Normalizes x to (0, 1), where start = 0 and end = 1.
 
template<typename T , typename A >
static constexpr auto eagine::math::blend (T v1, T v2, A alpha) noexcept
 Blends v1 and v2, using alpha as the blending factor.
 
template<typename T >
static constexpr auto eagine::math::inverse_logistic (T x) noexcept
 Calculates the inverse logistic (log(x) - log(1 - x)) of x.
 
template<typename T >
static constexpr auto eagine::math::logistic (T x) noexcept
 Calculates the logistic (1 / (1 + exp(-x))) of x.
 
template<typename T , typename C >
static constexpr auto eagine::math::sigmoid01 (T x, C c) noexcept
 Calculates the sigmoid of x. The value c controls steepness. More...
 
template<typename T >
static constexpr auto eagine::math::sigmoid01 (T x) noexcept
 Calculates the default sigmoid of x. More...
 
template<typename T >
static auto eagine::math::sine_sigmoid01 (T x)
 Calculates goniometric sigmoid (cos in interval (0, 1)) of x. More...
 
template<typename T >
static constexpr auto eagine::math::sine_wave01 (T x) noexcept
 Calculates sine of x, mapped to interval (0, 1). More...
 
template<typename T >
static constexpr auto eagine::math::cosine_wave01 (T x) noexcept
 Calculates cosine of x, mapped to interval (0, 1). More...
 
template<typename T , typename U = T>
static constexpr auto eagine::math::saw (T x, U u=T(1)) noexcept
 Calculates floating-point modulo of x in intervals of u.
 
template<typename T >
static constexpr auto eagine::math::factorial (T n) noexcept -> std::enable_if_t< std::is_integral_v< T >, T >
 Calculates factorial of n.
 
template<typename T >
static constexpr auto eagine::math::binomial (T n, T k) noexcept -> std::enable_if_t< std::is_integral_v< T >, T >
 Calculates binomial coefficient of n over k.
 
template<typename T , typename C >
static auto eagine::math::interpolate_linear (const T &a, const T &b, C coef)
 Linear interpolation between a and b. More...
 
template<typename T , typename C >
static auto eagine::math::lerp (const T &a, const T &b, C coef)
 Same as interpolate_linear. More...
 
template<typename T , typename C >
static auto eagine::math::smooth_lerp (const T &a, const T &b, C coef)
 Linear interpolation with coef transformed by sine_sigmoid01. More...
 
template<typename T , typename C >
static auto eagine::math::smooth_oscillate (const T &a, C coef)
 Smooth interpolation between negative a and a. More...
 
template<typename T , bool V>
static constexpr auto eagine::math::line_sphere_intersection (const line< T, V > &ray, const sphere< T, V > &sph) noexcept -> std::pair< optionally_valid< vector< T, 3, V >>, optionally_valid< vector< T, 3, V >>>
 Finds line-sphere intersection points. More...
 
template<typename T , bool V>
static constexpr auto eagine::math::nearest_line_sphere_intersection (const line< T, V > &ray, const sphere< T, V > &sph) noexcept -> optionally_valid< vector< T, 3, V >>
 Finds nearest line-sphere intersection point. More...
 
template<typename T , bool V>
static auto eagine::math::line_triangle_intersection (const line< T, V > &ray, const triangle< T, V > &tri) noexcept -> optionally_valid< vector< T, 3, V >>
 Finds line-triangle intersection point.
 
template<typename T , int N, bool V>
static auto eagine::math::operator<< (std::ostream &o, const vector< T, N, V > &v) -> std::ostream &
 Operator for writing vector into output stream.
 
template<typename T , int C, int R, bool V>
static auto eagine::math::operator<< (std::ostream &o, const matrix< T, C, R, true, V > &m) -> std::ostream &
 Operator for writing row-major matrix into output stream.
 
template<typename T , int C, int R, bool V>
static auto eagine::math::operator<< (std::ostream &o, const matrix< T, C, R, false, V > &m) -> std::ostream &
 Operator for writing column-major matrix into output stream.
 
template<typename T , int N, bool V>
static auto eagine::math::operator<< (std::ostream &o, const basic_line< T, N, V > &l) -> std::ostream &
 Operator for writing line into output stream.
 
template<typename T , int N, bool V>
static auto eagine::math::operator<< (std::ostream &o, const basic_triangle< T, N, V > &t) -> std::ostream &
 Operator for writing triangle into output stream.
 
template<typename T , bool V>
static auto eagine::math::operator<< (std::ostream &o, const sphere< T, V > &s) -> std::ostream &
 Operator for writing sphere into output stream.
 
template<typename T , int C, int R, bool RM, bool V>
static constexpr auto eagine::math::rows (const matrix< T, C, R, RM, V > &) noexcept
 Returns then number of matrix rows.
 
template<typename T , int C, int R, bool RM, bool V>
static constexpr auto eagine::math::columns (const matrix< T, C, R, RM, V > &) noexcept
 Returns then number of matrix columns.
 
template<typename T , int C, int R, bool RM, bool V>
static constexpr auto eagine::math::row_major (const matrix< T, C, R, RM, V > &) noexcept
 Indicates if a matrix is row-major.
 
template<typename T , int N, bool RM, bool V>
static constexpr auto eagine::math::dimension (const matrix< T, N, N, RM, V > &) noexcept
 Returns the dimension of a square matrix.
 
template<int CI, int RI, typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_cm (const matrix< T, C, R, false, V > &m) noexcept -> std::enable_if_t<(CI< C &&RI< R), T >
 Returns the matrix element at [CI, RI]. Column-major implementation.
 
template<int CI, int RI, typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_cm (const matrix< T, C, R, true, V > &m) noexcept -> std::enable_if_t<(CI< C &&RI< R), T >
 Returns the matrix element at [CI, RI]. Row-major implementation.
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_cm (const matrix< T, C, R, false, V > &m, int ci, int ri) noexcept -> T
 Returns the matrix element at [ci, ri]. Column-major implementation.
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_cm (const matrix< T, C, R, true, V > &m, int ci, int ri) noexcept -> T
 Returns the matrix element at [ci, ri]. Row-major implementation.
 
template<int RI, int CI, typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_rm (const matrix< T, C, R, false, V > &m) noexcept -> std::enable_if_t<(CI< C &&RI< R), T >
 Returns the matrix element at [RI, CI]. Column-major implementation.
 
template<int RI, int CI, typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_rm (const matrix< T, C, R, true, V > &m) noexcept -> std::enable_if_t<(CI< C &&RI< R), T >
 Returns the matrix element at [RI, CI]. Row-major implementation.
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_rm (const matrix< T, C, R, false, V > &m, int ri, int ci) noexcept -> T
 Returns the matrix element at [ri, ci]. Column-major implementation.
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::get_rm (const matrix< T, C, R, true, V > &m, int ri, int ci) noexcept -> T
 Returns the matrix element at [ri, ci]. Row-major implementation.
 
template<int CI, int RI, typename T , int C, int R, bool V>
static auto eagine::math::set_cm (matrix< T, C, R, false, V > &m, T v) noexcept -> std::enable_if_t<(CI< C &&RI< R)>
 Sets the matrix element at [CI, RI]. Column-major implementation.
 
template<int CI, int RI, typename T , int C, int R, bool V>
static auto eagine::math::set_cm (matrix< T, C, R, true, V > &m, T v) noexcept -> std::enable_if_t<(CI< C &&RI< R)>
 Sets the matrix element at [CI, RI]. Row-major implementation.
 
template<typename T , int C, int R, bool V>
static void eagine::math::set_cm (matrix< T, C, R, false, V > &m, int ci, int ri, T v) noexcept
 Sets the matrix element at [ci, ri]. Column-major implementation.
 
template<typename T , int C, int R, bool V>
static void eagine::math::set_cm (matrix< T, C, R, true, V > &m, int ci, int ri, T v) noexcept
 Sets the matrix element at [ci, ri]. Row-major implementation.
 
template<int RI, int CI, typename T , int C, int R, bool V>
static auto eagine::math::set_rm (matrix< T, C, R, false, V > &m, T v) noexcept -> std::enable_if_t<(CI< C &&RI< R)>
 Sets the matrix element at [RI, CI]. Column-major implementation.
 
template<int RI, int CI, typename T , int C, int R, bool V>
static auto eagine::math::set_rm (matrix< T, C, R, true, V > &m, T v) noexcept -> std::enable_if_t<(CI< C &&RI< R)>
 Sets the matrix element at [RI, CI]. Row-major implementation.
 
template<typename T , int C, int R, bool V>
static void eagine::math::set_rm (matrix< T, C, R, false, V > &m, int ri, int ci, T v) noexcept
 Sets the matrix element at [ri, ci]. Column-major implementation.
 
template<typename T , int C, int R, bool V>
static void eagine::math::set_rm (matrix< T, C, R, true, V > &m, int ri, int ci, T v) noexcept
 Sets the matrix element at [ri, ci]. Row-major implementation.
 
template<typename T , int C, int R, bool RM, bool V>
static auto eagine::math::transpose (const matrix< T, C, R, RM, V > &m) noexcept -> matrix< T, R, C, RM, V >
 Transposes a matrix.
 
template<typename T , int C, int R, bool RM, bool V>
static auto eagine::math::reorder (const matrix< T, C, R, RM, V > &m) noexcept -> matrix< T, C, R, !RM, V >
 Returns a matrix reordered (switches row/column major).
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::make_row_major (matrix< T, C, R, true, V > m) noexcept -> matrix< T, C, R, true, V >
 Returns a matrix ordered as row-major.
 
template<typename T , int C, int R, bool V>
static auto eagine::math::make_row_major (const matrix< T, C, R, false, V > &m) noexcept -> matrix< T, C, R, true, V >
 Returns a matrix ordered as row-major.
 
template<typename T , int C, int R, bool V>
static constexpr auto eagine::math::make_column_major (matrix< T, C, R, false, V > m) noexcept -> matrix< T, C, R, false, V >
 Returns a matrix ordered as column-major.
 
template<typename T , int C, int R, bool V>
static auto eagine::math::make_column_major (const matrix< T, C, R, true, V > &m) noexcept -> matrix< T, C, R, false, V >
 Returns a matrix ordered as column-major.
 
template<int I, typename T , int C, int R, bool RM, bool V>
static constexpr auto eagine::math::major_vector (const matrix< T, C, R, RM, V > &m) noexcept -> std::enable_if_t<(I<(RM ? R :C)), vector< T,(RM ? C :R), V >>
 Returns the I-th major vector of a matrix.
 
template<int I, typename T , int C, int R, bool RM, bool V>
static auto eagine::math::minor_vector (const matrix< T, C, R, RM, V > &m) noexcept -> std::enable_if_t<(I<(RM ? C :R)), vector< T,(RM ? R :C), V >>
 Returns the I-th minor vector of a matrix.
 
template<int I, typename T , int C, int R, bool V>
static constexpr auto eagine::math::row (const matrix< T, C, R, true, V > &m) noexcept -> vector< T, C, V >
 Returns the I-th row vector of a matrix. Row-major implementation.
 
template<int I, typename T , int C, int R, bool V>
static auto eagine::math::row (const matrix< T, C, R, false, V > &m) noexcept -> vector< T, C, V >
 Returns the I-th row vector of a matrix. Column-major implementation.
 
template<typename T , int R, int C, bool RM, bool V>
static auto eagine::math::row (const matrix< T, C, R, RM, V > &m, int i) noexcept -> vector< T, C, V >
 Returns the i-th row vector of a matrix.
 
template<int I, typename T , int C, int R, bool V>
static constexpr auto eagine::math::column (const matrix< T, C, R, false, V > &m) noexcept -> vector< T, R, V >
 Returns the I-th column vector of a matrix. Column-major implementation.
 
template<int I, typename T , int C, int R, bool V>
static auto eagine::math::column (const matrix< T, C, R, true, V > &m) noexcept -> vector< T, R, V >
 Returns the I-th column vector of a matrix. Row-major implementation.
 
template<typename T , int R, int C, bool RM, bool V>
static auto eagine::math::column (const matrix< T, C, R, RM, V > &m, int i) noexcept -> vector< T, R, V >
 Returns the i-th column vector of a matrix.
 
template<typename T , int M, int N, int K, bool RM1, bool RM2, bool V>
static auto eagine::math::multiply (const matrix< T, K, M, RM1, V > &m1, const matrix< T, N, K, RM2, V > &m2) noexcept -> matrix< T, N, M, RM1, V >
 Matrix multiplication function.
 
template<typename T , int C, int R, bool RM, bool V>
static auto eagine::math::multiply (const matrix< T, C, R, RM, V > &m, const vector< T, C, V > &v) noexcept -> vector< T, R, V >
 Matrix-vector multiplication function.
 
template<typename MC1 , typename MC2 , typename = std::enable_if_t< is_matrix_constructor<MC1>::value && is_matrix_constructor<MC2>::value && are_multiplicable<constructed_matrix_t<MC1>, constructed_matrix_t<MC2>>::value>>
static auto eagine::math::operator* (const MC1 &mc1, const MC2 &mc2) noexcept
 Multiplication operator for matrix constructors. More...
 
template<bool RM, typename MC >
static constexpr auto eagine::math::construct_matrix (const MC &c) noexcept -> std::enable_if_t< is_matrix_constructor_v< MC > &&is_row_major_v< constructed_matrix_t< MC >>==RM, constructed_matrix_t< MC >>
 Uses the specified matrix constructor c to construct a matrix.
 
template<typename MC1 , typename MC2 , typename = std::enable_if_t< is_matrix_constructor_v<MC1> && is_matrix_constructor_v<MC2> && are_multiplicable<constructed_matrix_t<MC1>, constructed_matrix_t<MC2>>::value>>
static auto eagine::math::multiply (const MC1 &mc1, const MC2 &mc2) noexcept
 Multiplies the results of two matrix constructors. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination (matrix< T, Ca, R, true, V > &a, matrix< T, Cb, R, true, V > &b) noexcept -> bool
 Implements gaussian elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination (matrix< T, Ca, R, false, V > &a, matrix< T, Cb, R, true, V > &b) noexcept -> bool
 Implements gaussian elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination (matrix< T, Ca, R, true, V > &a, matrix< T, Cb, R, false, V > &b) noexcept -> bool
 Implements gaussian elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination (matrix< T, Ca, R, false, V > &a, matrix< T, Cb, R, false, V > &b) noexcept -> bool
 Implements gaussian elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination (matrix< T, Ca, R, true, V > &a, matrix< T, Cb, R, true, V > &b) noexcept -> bool
 Implements gauss-jordan elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination (matrix< T, Ca, R, false, V > &a, matrix< T, Cb, R, true, V > &b) noexcept -> bool
 Implements gauss-jordan elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination (matrix< T, Ca, R, true, V > &a, matrix< T, Cb, R, false, V > &b) noexcept -> bool
 Implements gauss-jordan elimination on matrices a and b. More...
 
template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination (matrix< T, Ca, R, false, V > &a, matrix< T, Cb, R, false, V > &b) noexcept -> bool
 Implements gauss-jordan elimination on matrices a and b. More...
 
template<typename T , int N, bool RM, bool V>
static auto eagine::math::inverse_matrix (matrix< T, N, N, RM, V > m) noexcept -> optionally_valid< matrix< T, N, N, RM, V >>
 Returns the inverse matrix to the matrix passed as argument.
 
template<typename Ctr , typename = std::enable_if_t<is_matrix_constructor_v<Ctr>>>
static auto eagine::math::inverse_matrix (const Ctr &ctr) noexcept
 Returns the inverse matrix to the matrix constructed by the argument.
 
template<typename T , int N, bool V>
static constexpr auto eagine::math::dimension (const vector< T, N, V > &) noexcept
 Returns the dimension of a vector.
 
template<typename T , int N, bool V>
static auto eagine::math::is_zero (const vector< T, N, V > &v) noexcept -> bool
 Tests if a vector has zero lenght.
 
template<typename T , int N, bool V>
static constexpr auto eagine::math::dot (const vector< T, N, V > &a, const vector< T, N, V > &b) noexcept
 Vector dot product.
 
template<typename T , bool V>
static auto eagine::math::perpendicular (const vector< T, 2, V > &a) noexcept
 Returns a vector perpendicular to argument.
 
template<typename T , bool V>
static auto eagine::math::cross (const vector< T, 3, V > &a, const vector< T, 3, V > &b) noexcept
 3D vector cross product.
 
template<typename T , int N, bool V>
static constexpr auto eagine::math::magnitude (const vector< T, N, V > &a) noexcept
 Returns the magnitude of a vector. Same as length.
 
template<typename T , int N, bool V>
static constexpr auto eagine::math::length (const vector< T, N, V > &a) noexcept
 Returns the length of a vector.
 
template<typename T , int N, bool V>
static auto eagine::math::normalized (const vector< T, N, V > &a) noexcept
 Returns normalized argument.
 
template<typename T , int N, bool V>
static constexpr auto eagine::math::distance (const vector< T, N, V > &a, const vector< T, N, V > &b) noexcept
 Returns the distance between two vectors.
 

Variables

template<typename X >
const auto eagine::math::is_row_major_v
 Trait indicating if a matrix type is row-major.
 
template<typename X >
constexpr auto eagine::math::is_matrix_constructor_v
 Trait indicating if a type X is a matrix constructor. More...
 
static constexpr const auto eagine::math::pi
 The pi constant. More...
 
static const auto eagine::math::phi
 The phi constant. More...
 

Detailed Description

Typedef Documentation

◆ matrix_reflection_x

template<typename T , bool V>
using eagine::math::matrix_reflection_x = typedef convertible_matrix_constructor<reflection_x<matrix<T, 4, 4, true, V> >>

◆ matrix_reflection_y

template<typename T , bool V>
using eagine::math::matrix_reflection_y = typedef convertible_matrix_constructor<reflection_y<matrix<T, 4, 4, true, V> >>

◆ matrix_reflection_z

template<typename T , bool V>
using eagine::math::matrix_reflection_z = typedef convertible_matrix_constructor<reflection_z<matrix<T, 4, 4, true, V> >>

◆ matrix_rotation_x

◆ matrix_rotation_y

◆ matrix_rotation_z

◆ matrix_scale

template<typename T , bool V>
using eagine::math::matrix_scale = typedef convertible_matrix_constructor<scale<matrix<T, 4, 4, true, V> >>

Alias for constructor of scale transformation matrix.

See also
matrix_translation
matrix_rotation_x
matrix_rotation_y
matrix_rotation_z
matrix_uniform_scale

◆ matrix_translation

◆ matrix_uniform_scale

template<typename T , bool V>
using eagine::math::matrix_uniform_scale = typedef convertible_matrix_constructor<uniform_scale<matrix<T, 4, 4, true, V> >>

Function Documentation

◆ cosine_wave01()

template<typename T >
static constexpr auto eagine::math::cosine_wave01 ( x)
staticconstexprnoexcept

Calculates cosine of x, mapped to interval (0, 1).

Precondition
0 <= x <= 1

◆ gauss_elimination() [1/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination ( matrix< T, Ca, R, false, V > &  a,
matrix< T, Cb, R, false, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gaussian elimination on matrices a and b.

See also
gauss_jordan_elimination

◆ gauss_elimination() [2/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination ( matrix< T, Ca, R, false, V > &  a,
matrix< T, Cb, R, true, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gaussian elimination on matrices a and b.

See also
gauss_jordan_elimination

◆ gauss_elimination() [3/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination ( matrix< T, Ca, R, true, V > &  a,
matrix< T, Cb, R, false, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gaussian elimination on matrices a and b.

See also
gauss_jordan_elimination

◆ gauss_elimination() [4/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_elimination ( matrix< T, Ca, R, true, V > &  a,
matrix< T, Cb, R, true, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gaussian elimination on matrices a and b.

See also
gauss_jordan_elimination

Referenced by eagine::math::gauss_elimination(), and eagine::math::gauss_jordan_elimination().

◆ gauss_jordan_elimination() [1/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination ( matrix< T, Ca, R, false, V > &  a,
matrix< T, Cb, R, false, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gauss-jordan elimination on matrices a and b.

See also
gauss_elimination
inverse_matrix

◆ gauss_jordan_elimination() [2/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination ( matrix< T, Ca, R, false, V > &  a,
matrix< T, Cb, R, true, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gauss-jordan elimination on matrices a and b.

See also
gauss_elimination
inverse_matrix

◆ gauss_jordan_elimination() [3/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination ( matrix< T, Ca, R, true, V > &  a,
matrix< T, Cb, R, false, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gauss-jordan elimination on matrices a and b.

See also
gauss_elimination
inverse_matrix

◆ gauss_jordan_elimination() [4/4]

template<typename T , int Ca, int Cb, int R, bool V>
static auto eagine::math::gauss_jordan_elimination ( matrix< T, Ca, R, true, V > &  a,
matrix< T, Cb, R, true, V > &  b 
) -> bool
inlinestaticnoexcept

Implements gauss-jordan elimination on matrices a and b.

See also
gauss_elimination
inverse_matrix

Referenced by eagine::math::gauss_jordan_elimination(), and eagine::math::inverse_matrix().

◆ interpolate_linear()

template<typename T , typename C >
static auto eagine::math::interpolate_linear ( const T &  a,
const T &  b,
coef 
)
inlinestatic

Linear interpolation between a and b.

See also
lerp

Referenced by eagine::math::lerp().

◆ lerp()

template<typename T , typename C >
static auto eagine::math::lerp ( const T &  a,
const T &  b,
coef 
)
inlinestatic

Same as interpolate_linear.

See also
interpolate_linear

Referenced by eagine::math::smooth_lerp().

◆ line_sphere_intersection()

template<typename T , bool V>
static constexpr auto eagine::math::line_sphere_intersection ( const line< T, V > &  ray,
const sphere< T, V > &  sph 
) -> std:: pair<optionally_valid<vector<T, 3, V>>, optionally_valid<vector<T, 3, V>>>
staticconstexprnoexcept

Finds line-sphere intersection points.

See also
nearest_line_sphere_intersection

◆ multiply()

template<typename MC1 , typename MC2 , typename = std::enable_if_t< is_matrix_constructor_v<MC1> && is_matrix_constructor_v<MC2> && are_multiplicable<constructed_matrix_t<MC1>, constructed_matrix_t<MC2>>::value>>
static auto eagine::math::multiply ( const MC1 &  mc1,
const MC2 &  mc2 
)
inlinestaticnoexcept

Multiplies the results of two matrix constructors.

This is typically more efficient than constructing the two matrices and multiplying them.

◆ nearest_line_sphere_intersection()

template<typename T , bool V>
static constexpr auto eagine::math::nearest_line_sphere_intersection ( const line< T, V > &  ray,
const sphere< T, V > &  sph 
) -> optionally_valid<vector<T, 3, V>>
staticconstexprnoexcept

Finds nearest line-sphere intersection point.

See also
line_sphere_intersection

◆ operator*()

template<typename MC1 , typename MC2 , typename = std::enable_if_t< is_matrix_constructor<MC1>::value && is_matrix_constructor<MC2>::value && are_multiplicable<constructed_matrix_t<MC1>, constructed_matrix_t<MC2>>::value>>
static auto eagine::math::operator* ( const MC1 &  mc1,
const MC2 &  mc2 
)
inlinestaticnoexcept

Multiplication operator for matrix constructors.

Doing multiplication on matrix constructors is typically more efficient than doing multiplication on the constructed matrices, because it can save row/column reordering operations.

◆ sigmoid01() [1/2]

template<typename T >
static constexpr auto eagine::math::sigmoid01 ( x)
staticconstexprnoexcept

Calculates the default sigmoid of x.

Precondition
0 <= x <= 1

◆ sigmoid01() [2/2]

template<typename T , typename C >
static constexpr auto eagine::math::sigmoid01 ( x,
c 
)
staticconstexprnoexcept

Calculates the sigmoid of x. The value c controls steepness.

Precondition
0 <= x <= 1

Referenced by eagine::animated_value< T, F, S >::get(), and eagine::math::sigmoid01().

◆ sine_sigmoid01()

template<typename T >
static auto eagine::math::sine_sigmoid01 ( x)
inlinestatic

Calculates goniometric sigmoid (cos in interval (0, 1)) of x.

Precondition
0 <= x <= 1

Referenced by eagine::math::smooth_lerp().

◆ sine_wave01()

template<typename T >
static constexpr auto eagine::math::sine_wave01 ( x)
staticconstexprnoexcept

Calculates sine of x, mapped to interval (0, 1).

Precondition
0 <= x <= 1

◆ smooth_lerp()

template<typename T , typename C >
static auto eagine::math::smooth_lerp ( const T &  a,
const T &  b,
coef 
)
inlinestatic

Linear interpolation with coef transformed by sine_sigmoid01.

See also
interpolate_linear
sine_sigmoid01
Examples
application/019_scaled_cubes/resources.cpp.

Referenced by eagine::oglp::orbiting_camera::orbit(), and eagine::math::smooth_oscillate().

◆ smooth_oscillate()

template<typename T , typename C >
static auto eagine::math::smooth_oscillate ( const T &  a,
coef 
)
inlinestatic

Smooth interpolation between negative a and a.

See also
smooth_lerp

Variable Documentation

◆ is_matrix_constructor_v

template<typename X >
constexpr auto eagine::math::is_matrix_constructor_v
constexpr

Trait indicating if a type X is a matrix constructor.

Matrix constructor types define a nullary call operator that can construct a matrix instantiation.

◆ phi

eagine::math::phi
static

The phi constant.

See also
pi

◆ pi

eagine::math::pi
staticconstexpr

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).