Radium Engine
1.5.20
|
This namespace contains usefull math functions. More...
Functions | |
void | print (const MatrixN &matrix) |
template<typename Vector > | |
Vector | floor (const Vector &v) |
Component-wise floor() function on a floating-point vector. | |
template<typename Vector > | |
Vector | ceil (const Vector &v) |
Component-wise ceil() function on a floating-point vector. | |
template<typename Vector > | |
Vector | trunc (const Vector &v) |
Component-wise trunc() function on a floating-point vector. | |
template<typename Derived , typename DerivedA , typename DerivedB > | |
Derived::PlainMatrix | clamp (const Eigen::MatrixBase< Derived > &v, const Eigen::MatrixBase< DerivedA > &min, const Eigen::MatrixBase< DerivedB > &max) |
Component-wise clamp() function on a floating-point vector. | |
template<typename Derived > | |
Derived::PlainMatrix | clamp (const Eigen::MatrixBase< Derived > &v, const Scalar &min, const Scalar &max) |
Component-wise clamp() function on a floating-point vector. | |
template<typename S > | |
bool | checkInvalidNumbers (Eigen::Ref< Eigen::Quaternion< S > > q, const bool FAIL_ON_ASSERT=false) |
Call std::isfinite on quaternion entries. | |
template<typename Matrix_ > | |
bool | checkInvalidNumbers (Eigen::Ref< const Matrix_ > matrix, const bool FAIL_ON_ASSERT=false) |
void | getOrthogonalVectors (const Vector3 &fx, Eigen::Ref< Vector3 > fy, Eigen::Ref< Vector3 > fz) |
template<typename Vector_ > | |
Scalar | angle (const Vector_ &v1, const Vector_ &v2) |
template<typename Vector_ > | |
Vector_ | slerp (const Vector_ &v1, const Vector_ &v2, Scalar t) |
Vector3 | projectOnPlane (const Vector3 &planePos, const Vector3 &planeNormal, const Vector3 &point) |
template<typename Vector_ > | |
Scalar | cotan (const Vector_ &v1, const Vector_ &v2) |
template<typename Vector_ > | |
Scalar | cos (const Vector_ &v1, const Vector_ &v2) |
template<typename Vector_ > | |
Scalar | getNormAndNormalize (Vector_ &v) |
template<typename Vector_ > | |
Scalar | getNormAndNormalizeSafe (Vector_ &v) |
template<typename Scalar > | |
Eigen::ParametrizedLine< Scalar, 3 > | transformRay (const Eigen::Transform< Scalar, 3, Eigen::Affine > &t, const Eigen::ParametrizedLine< Scalar, 3 > &r) |
Matrix4 | lookAt (const Vector3 &position, const Vector3 &target, const Vector3 &up) |
Matrix4 | perspective (Scalar fovy, Scalar aspect, Scalar near, Scalar zfar) |
Matrix4 | orthographic (Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near, Scalar zfar) |
Quaternion | scale (const Quaternion &q, const Scalar k) |
Returns the quaternion q multipled by a scalar factor of k. | |
Quaternion | add (const Quaternion &q1, const Quaternion &q2) |
Returns the sum of two quaternions. | |
Quaternion | addQlerp (const Quaternion &q1, const Quaternion &q2) |
void | getSwingTwist (const Quaternion &in, Quaternion &swingOut, Quaternion &twistOut) |
template<typename Vector_ > | |
Vector_ | floor (const Vector_ &v) |
template<typename Vector_ > | |
Vector_ | ceil (const Vector_ &v) |
template<typename Vector_ > | |
Vector_ | trunc (const Vector_ &v) |
template<typename DerivedA , typename DerivedB > | |
bool | allClose (const Eigen::DenseBase< DerivedA > &a, const Eigen::DenseBase< DerivedB > &b, const typename DerivedA::RealScalar &rtol=Eigen::NumTraits< typename DerivedA::RealScalar >::dummy_precision(), const typename DerivedA::RealScalar &atol=Eigen::NumTraits< typename DerivedA::RealScalar >::epsilon()) |
Returns True if two arrays are element-wise equal within a tolerance. | |
constexpr Scalar | toRadians (Scalar a) |
Useful functions. | |
constexpr Scalar | toDegrees (Scalar a) |
Converts an angle from radians to degrees. | |
template<class T > | |
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type | areApproxEqual (T x, T y, T espilonBoostFactor=T(10)) |
Compare two numbers such that |x-y| < espilon*epsilonBoostFactor. | |
template<typename Vector_Or_Scalar > | |
bool | checkRange (const Vector_Or_Scalar &v, const Scalar &min, const Scalar &max) |
template<typename T > | |
T | ipow (const T &x, uint exp) |
Run-time exponent version. | |
template<uint N, typename T > | |
constexpr T | ipow (const T &x) |
Compile-time exponent version. | |
template<typename T > | |
constexpr int | signum (T x, std::true_type) |
template<typename T > | |
constexpr int | sign (const T &val) |
Returns the sign of any numeric type as { -1, 0, 1}. | |
template<typename T > | |
constexpr T | signNZ (const T &val) |
template<typename T > | |
constexpr T | saturate (T v) |
Clamps the value between 0 and 1. | |
template<typename T > | |
constexpr T | lerp (const T &a, const T &b, Scalar t) |
Returns the linear interpolation between a and b. | |
template<typename T > | |
T | smoothstep (T edge0, T edge1, T x) |
As define by https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml. | |
template<typename T , template< typename, int... > typename M, int... p> | |
M< T, p... > | smoothstep (T edge0, T edge1, M< T, p... > v) |
Linear Interpolation | |
template<typename T > | |
T | linearInterpolate (const T &v0, const T &v1, const Scalar t) |
template<> | |
Core::Quaternion | linearInterpolate< Core::Quaternion > (const Core::Quaternion &q0, const Core::Quaternion &q1, const Scalar t) |
template<> | |
Core::Transform | linearInterpolate< Core::Transform > (const Core::Transform &T0, const Core::Transform &T1, const Scalar t) |
Variables | |
constexpr Scalar | Sqrt2 = Scalar( 1.41421356237309504880 ) |
Mathematical constants casted to Scalar. Values taken from math.h. | |
constexpr Scalar | e = Scalar( 2.7182818284590452354 ) |
constexpr Scalar | Pi = Scalar( 3.14159265358979323846 ) |
constexpr Scalar | InvPi = Scalar( 0.31830988618379067154 ) |
constexpr Scalar | PiDiv2 = Scalar( 1.57079632679489661923 ) |
constexpr Scalar | PiDiv3 = Scalar( 1.04719755119659774615 ) |
constexpr Scalar | PiDiv4 = Scalar( 0.78539816339744830962 ) |
constexpr Scalar | PiDiv6 = Scalar( 0.52359877559829887307 ) |
constexpr Scalar | PiMul2 = Scalar( 2 * Pi ) |
constexpr Scalar | toRad = Scalar( Pi / Scalar( 180.0 ) ) |
constexpr Scalar | toDeg = Scalar( Scalar( 180.0 ) * InvPi ) |
constexpr Scalar | machineEps = std::numeric_limits<Scalar>::epsilon() |
This namespace contains usefull math functions.
|
inline |
Returns the sum of two quaternions.
Definition at line 245 of file LinearAlgebra.hpp.
|
inline |
Returns the sum of two quaternions, resolving antipodality by flipping the sign of q2 if q1.q2 is negative. This operation is usually denoted as a circled + sign, forming the basis of the QLERP algorithm. See "Spherical Blend Skinning" (Kavan & Zara 2005) for more details.
Definition at line 249 of file LinearAlgebra.hpp.
bool Ra::Core::Math::allClose | ( | const Eigen::DenseBase< DerivedA > & | a, |
const Eigen::DenseBase< DerivedB > & | b, | ||
const typename DerivedA::RealScalar & | rtol = Eigen::NumTraits<typename DerivedA::RealScalar>::dummy_precision(), | ||
const typename DerivedA::RealScalar & | atol = Eigen::NumTraits<typename DerivedA::RealScalar>::epsilon() ) |
Returns True if two arrays are element-wise equal within a tolerance.
The tolerance values are positive, typically very small numbers. The relative difference (rtol * abs(b)) and the absolute difference atol are added together to compare against the absolute difference between a and b.
Parameters:
a,b | Input Matrix to compare |
rtol | The relative tolerance parameter (see Notes). |
atol | The absolute tolerance parameter (see Notes). |
Definition at line 392 of file LinearAlgebra.hpp.
|
inline |
Get the angle between two vectors. Works for types where the cross product is defined (i.e. 2D and 3D vectors).
Definition at line 206 of file LinearAlgebra.hpp.
|
inline |
|
inline |
Definition at line 179 of file LinearAlgebra.hpp.
|
inline |
Call std::isfinite on matrix entry. Dense version
Definition at line 362 of file LinearAlgebra.hpp.
|
inline |
Call std::isfinite on quaternion entries.
Definition at line 59 of file LinearAlgebra.hpp.
|
inline |
Scalar or component-wise range check. Note: a definition of clamp must be available:
using std::clamp;
beforehand) Definition at line 53 of file Math.hpp.
|
inline |
Component-wise clamp() function on a floating-point vector.
Definition at line 193 of file LinearAlgebra.hpp.
|
inline |
Component-wise clamp() function on a floating-point vector.
Definition at line 201 of file LinearAlgebra.hpp.
|
inline |
Get the cosine of the angle between two vectors.
Definition at line 216 of file LinearAlgebra.hpp.
|
inline |
Get the cotangent of the angle between two vectors. Works for vector types where dot and cross product is defined (2D or 3D vectors).
Definition at line 211 of file LinearAlgebra.hpp.
|
inline |
Definition at line 172 of file LinearAlgebra.hpp.
|
inline |
Normalize a vector and returns its norm before normalization. If the vector's norm is 0, the vector's components will be overwritten by NaNs
Definition at line 221 of file LinearAlgebra.hpp.
|
inline |
Normalize a vector and returns its norm before normalization. If the vector's norm is 0, the vector remains null
Definition at line 228 of file LinearAlgebra.hpp.
|
inline |
Get two vectors orthogonal to a given vector.
Definition at line 259 of file LinearAlgebra.hpp.
|
inline |
Decompose a given rotation Qin into a swing rotation and a twist rotation. Qswing is a rotation whose axis lies in the XY plane and Qtwist is a rotation about axis Z. such as Qin = Qswing * Qtwist If the rotation is already around axis z, Qswing will be set to identity and Qtwist equal to Qin
Definition at line 285 of file LinearAlgebra.hpp.
|
inlineconstexpr |
|
inline |
|
inlineconstexpr |
|
inline |
result
the linear interpolation between v0
and v1
, according to t
. Definition at line 18 of file Interpolation.hpp.
|
inline |
result
the spherical linear interpolation between q0
and q1
, according to t
. Definition at line 27 of file Interpolation.hpp.
|
inline |
result
the linear interpolation between q0
and q1
, according to t
. To do so, the rotational parts are interpolated through spherical linear interpolation while the translational parts are interpolated through linear interpolation. Definition at line 40 of file Interpolation.hpp.
|
inline |
Definition at line 316 of file LinearAlgebra.hpp.
|
inline |
Definition at line 346 of file LinearAlgebra.hpp.
|
inline |
Definition at line 330 of file LinearAlgebra.hpp.
|
inline |
Definition at line 157 of file LinearAlgebra.hpp.
|
inline |
Definition at line 270 of file LinearAlgebra.hpp.
|
inlineconstexpr |
|
inline |
Returns the quaternion q multipled by a scalar factor of k.
Definition at line 254 of file LinearAlgebra.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
Get the spherical linear interpolation between two unit non-colinear vectors. works for types where the cross-product is defined (i.e. 2D and 3D vectors).
Definition at line 275 of file LinearAlgebra.hpp.
M< T, p... > Ra::Core::Math::smoothstep | ( | T | edge0, |
T | edge1, | ||
M< T, p... > | v ) |
T Ra::Core::Math::smoothstep | ( | T | edge0, |
T | edge1, | ||
T | x ) |
As define by https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml.
Definition at line 132 of file Math.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
Transform a ray, direction is only transformed by linear part of the transformation, while origin is fully transformed corresponds to t*r
t | : transform matrix |
r | : ray to transform |
Definition at line 236 of file LinearAlgebra.hpp.
|
inline |
Definition at line 186 of file LinearAlgebra.hpp.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |