Math library
Topics
Types
-
Used to specify a 2D rectangle region using position and size.
-
Used to specify a 2D rectangle region using offsets with its container rectangle.
-
Used to specify a 3D box region using position and size.
-
Used to specify a 3D box region using offsets with its container box.
-
3x3 matrix type with f32 components.
-
Unaligned 3x2 matrix with f32 elements.
-
Unaligned 3x3 matrix with f32 elements.
-
4x4 matrix type with f32 components.
-
Unaligned 4x3 matrix with f32 elements.
-
Unaligned 4x4 matrix with f32 elements.
Alias types
-
using OffsetRectI = OffsetRect
A instanced type of OffsetRect that uses i32 as value type.
-
using OffsetRectU = OffsetRect
A instanced type of OffsetRect that uses u32 as value type.
-
using OffsetRectF = OffsetRect
A instanced type of OffsetRect that uses f32 as value type.
Constants
-
The constant value
pi
. -
The constant value
pi * 2.0
. -
The constant value
1.0 / pi
. -
The constant value
0.5 / pi
. -
The constant value
pi / 2.0
. -
The constant value
pi / 4.0
. -
The INF value for f32 type.
-
The INF value for f64 type.
-
The NaN value for f32 type.
-
The NaN value for f64 type.
Functions
-
constexpr f32 deg_to_rad(f32 degrees)
Converts degree angle to radian angle.
-
constexpr f32 rad_to_deg(f32 radians)
Converts radian angle to degree angle.
-
constexpr bool is_pow_of_two(_Ty n)
Check whether the provided number is power of two.
-
_VTy lerp(_VTy f1, _VTy f2, _TTy t)
Performs linear interpolation on the given values.
-
f32 smoothstep(f32 f1, f32 f2, f32 t)
Performs smoothstep interpolation on the given values.
-
_Ty1 clamp(_Ty1 v, _Ty2 min_v, _Ty3 max_v)
Clamps the value to the specified range.
-
constexpr _Ty gcd(_Ty a, _Ty b)
Calculates the Greatest Common Divisor of two numbers.
-
Float3x3 operator+(const Float3x3 &m1, const Float3x3 &m2)
Adds two matrices. The addition is performed on every component of two matrices.
-
Float3x3 operator+(const Float3x3 &m1, f32 s)
Adds one matrix with one scalar. The scalar will be added to every component of the matrix.
-
Float3x3 operator+(f32 s, const Float3x3 &m1)
Adds one matrix with one scalar. The scalar will be added to every component of the matrix.
-
Float3x3 operator-(const Float3x3 &m1, const Float3x3 &m2)
Subtracts one matrix from another matrix (m1 - m2). The subtraction is performed on every component of two matrices.
-
Float3x3 operator-(const Float3x3 &m1, f32 s)
Subtracts one scalar from one matrix (m1 - s). The scalar will be subtracted from every component of the matrix.
-
Float3x3 operator-(f32 s, const Float3x3 &m1)
Subtracts one matrix from one scalar (s - m1). This behaves like creating one matrix filled with scalar
s
, then subtracting matrixm1
from the created matrix. -
Float3x3 operator*(const Float3x3 &m1, const Float3x3 &m2)
Multiplies two matrices. The multiplication is performed on every component of two matrices.
-
Float3x3 operator*(const Float3x3 &m1, f32 s)
Multiplies one matrix with one scalar. The scalar will be multiplied to every component of the matrix.
-
Float3x3 operator*(f32 s, const Float3x3 &m1)
Multiplies one matrix with one scalar. The scalar will be multiplied to every component of the matrix.
-
Float3x3 operator/(const Float3x3 &m1, const Float3x3 &m2)
Divides one matrix with another matrix (m1 / m2). The division is performed on every component of two matrices.
-
Float3x3 operator/(const Float3x3 &m1, f32 s)
Divides one scalar with one matrix (m1 / s). The scalar will be divided from every component of the matrix.
-
Float3x3 operator/(f32 s, const Float3x3 &m1)
Divides one matrix with one scalar (s / m1). This behaves like creating one matrix filled with scalar
s
, then dividing the created matrix with matrixm1
. -
Float3 mul(const Float3 &vec, const Float3x3 &mat)
Performs matrix multiplication between one vector and one matrix.
-
Float3 mul(const Float3x3 &mat, const Float3 &vec)
Performs matrix multiplication between one matrix and one vector.
-
Float3x3 mul(const Float3x3 &m1, const Float3x3 &m2)
Performs matrix multiplication between two matrices.
-
f32 determinant(const Float3x3 &mat)
Computes the determinant of the specified matrix.
-
Float3x3 transpose(const Float3x3 &mat)
Computes the transpose matrix of the specified matrix.
-
Float3x3 inverse(const Float3x3 &mat, f32 *out_determinant=nullptr)
Computes the inversed matrix of the specified matrix.
-
Float4x4 operator+(const Float4x4 &m1, const Float4x4 &m2)
Adds two matrices. The addition is performed on every component of two matrices.
-
Float4x4 operator+(const Float4x4 &m1, f32 s)
Adds one matrix with one scalar. The scalar will be added to every component of the matrix.
-
Float4x4 operator+(f32 s, const Float4x4 &m1)
Adds one matrix with one scalar. The scalar will be added to every component of the matrix.
-
Float4x4 operator-(const Float4x4 &m1, const Float4x4 &m2)
Subtracts one matrix from another matrix (m1 - m2). The subtraction is performed on every component of two matrices.
-
Float4x4 operator-(const Float4x4 &m1, f32 s)
Subtracts one scalar from one matrix (m1 - s). The scalar will be subtracted from every component of the matrix.
-
Float4x4 operator-(f32 s, const Float4x4 &m1)
Subtracts one matrix from one scalar (s - m1). This behaves like creating one matrix filled with scalar
s
, then subtracting matrixm1
from the created matrix. -
Float4x4 operator*(const Float4x4 &m1, const Float4x4 &m2)
Multiplies two matrices. The multiplication is performed on every component of two matrices.
-
Float4x4 operator*(const Float4x4 &m1, f32 s)
Multiplies one matrix with one scalar. The scalar will be multiplied to every component of the matrix.
-
Float4x4 operator*(f32 s, const Float4x4 &m1)
Multiplies one matrix with one scalar. The scalar will be multiplied to every component of the matrix.
-
Float4x4 operator/(const Float4x4 &m1, const Float4x4 &m2)
Divides one matrix with another matrix (m1 / m2). The division is performed on every component of two matrices.
-
Float4x4 operator/(const Float4x4 &m1, f32 s)
Divides one scalar with one matrix (m1 / s). The scalar will be divided from every component of the matrix.
-
Float4x4 operator/(f32 s, const Float4x4 &m1)
Divides one matrix with one scalar (s / m1). This behaves like creating one matrix filled with scalar
s
, then dividing the created matrix with matrixm1
. -
Float4 mul(const Float4 &vec, const Float4x4 &mat)
Performs matrix multiplication between one vector and one matrix.
-
Float4 mul(const Float4x4 &mat, const Float4 &vec)
Performs matrix multiplication between one matrix and one vector.
-
Float4x4 mul(const Float4x4 &mat1, const Float4x4 &mat2)
Performs matrix multiplication between two matrices.
-
f32 determinant(const Float4x4 &mat)
Computes the determinant of the specified matrix.
-
Float4x4 transpose(const Float4x4 &mat)
Computes the transpose matrix of the specified matrix.
-
Float4x4 inverse(const Float4x4 &mat, f32 *out_determinant=nullptr)
Computes the inversed matrix of the specified matrix.
-
Gets the type object of Float3x3.
-
Gets the type object of Float4x4.