![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
Maths classes and functions. More...
Classes | |
struct | gf::Matrix< T, ROWS, COLS > |
General purpose math matrix. More... | |
struct | gf::Matrix< T, 2, 2 > |
A 2x2 matrix. More... | |
struct | gf::Matrix< T, 3, 3 > |
A 3x3 matrix. More... | |
struct | gf::Matrix< T, 4, 4 > |
A 4x4 matrix. More... | |
struct | gf::Range< T > |
A half-open range of values. More... | |
struct | gf::Range< T >::Iterator |
A range iterator. More... | |
struct | gf::PositionRange< T > |
A 2D range. More... | |
struct | gf::PositionRange< T >::Iterator |
An iterator for a 2D range. More... | |
struct | gf::NeighborSquareRange< T > |
A 2D range. More... | |
struct | gf::NeighborSquareRange< T >::Iterator |
An iterator for a 2D range. More... | |
struct | gf::NeighborDiamondRange< T > |
A 2D range. More... | |
struct | gf::NeighborDiamondRange< T >::Iterator |
An iterator for a 2D range. More... | |
struct | gf::Vector< T, N > |
General purpose math vector. More... | |
struct | gf::Vector< T, 2 > |
A 2D vector. More... | |
struct | gf::Vector< T, 3 > |
A 3D vector. More... | |
struct | gf::Vector< T, 4 > |
A 4D vector. More... | |
Typedefs | |
template<typename T > | |
using | gf::Step = T(*)(T) |
A step is a function with special features. More... | |
using | gf::Matrix2f = Matrix< float, 2, 2 > |
A float square matrix of size 2. More... | |
using | gf::Matrix2d = Matrix< double, 2, 2 > |
A double square matrix of size 2. More... | |
using | gf::Matrix3f = Matrix< float, 3, 3 > |
A float square matrix of size 3. More... | |
using | gf::Matrix3d = Matrix< double, 3, 3 > |
A double square matrix of size 3. More... | |
using | gf::Matrix4f = Matrix< float, 4, 4 > |
A float square matrix of size 4. More... | |
using | gf::Matrix4d = Matrix< double, 4, 4 > |
A double square matrix of size 4. More... | |
using | gf::RangeF = Range< float > |
A float range. More... | |
using | gf::RangeI = Range< int > |
A int range. More... | |
using | gf::RangeU = Range< unsigned > |
A unsigned range. More... | |
using | gf::RangeZ = Range< std::size_t > |
A std::size_t range. More... | |
using | gf::Vector2f = Vector< float, 2 > |
A float vector with 2 components. More... | |
using | gf::Vector3f = Vector< float, 3 > |
A float vector with 3 components. More... | |
using | gf::Vector4f = Vector< float, 4 > |
A float vector with 4 components. More... | |
using | gf::Vector2d = Vector< double, 2 > |
A double vector with 2 components. More... | |
using | gf::Vector3d = Vector< double, 3 > |
A double vector with 3 components. More... | |
using | gf::Vector4d = Vector< double, 4 > |
A double vector with 4 components. More... | |
using | gf::Vector2i = Vector< int, 2 > |
A int vector with 2 components. More... | |
using | gf::Vector3i = Vector< int, 3 > |
A int vector with 3 components. More... | |
using | gf::Vector4i = Vector< int, 4 > |
A int vector with 4 components. More... | |
using | gf::Vector2u = Vector< unsigned, 2 > |
A unsigned vector with 2 components. More... | |
using | gf::Vector3u = Vector< unsigned, 3 > |
A unsigned vector with 3 components. More... | |
using | gf::Vector4u = Vector< unsigned, 4 > |
A unsigned vector with 4 components. More... | |
using | gf::Vector2z = Vector< std::size_t, 2 > |
A std::size_t vector with 2 components. More... | |
using | gf::Vector3z = Vector< std::size_t, 3 > |
A std::size_t vector with 3 components. More... | |
using | gf::Vector4z = Vector< std::size_t, 4 > |
A std::size_t vector with 4 components. More... | |
using | gf::Vector2b = Vector< bool, 2 > |
A bool vector with 2 components. More... | |
using | gf::Vector3b = Vector< bool, 3 > |
A bool vector with 3 components. More... | |
using | gf::Vector4b = Vector< bool, 4 > |
A bool vector with 4 components. More... | |
template<typename T > | |
using | gf::Color3 = Vector< T, 3 > |
A color vector with 3 components. More... | |
template<typename T > | |
using | gf::Color4 = Vector< T, 4 > |
A color vector with 4 components. More... | |
using | gf::Color3f = Color3< float > |
A float color vector with 3 components. More... | |
using | gf::Color4f = Color4< float > |
A float color vector with 4 components. More... | |
using | gf::Color3d = Color3< double > |
A double color vector with 3 components. More... | |
using | gf::Color4d = Color4< double > |
A double color vector with 4 components. More... | |
using | gf::Color3u = Color3< uint8_t > |
A uint8_t color vector with 3 components. More... | |
using | gf::Color4u = Color4< uint8_t > |
A uint8_t color vector with 4 components. More... | |
template<typename T , std::size_t N> | |
using | gf::Distance = T(*)(Vector< T, N >, Vector< T, N >) |
A distance function. More... | |
template<typename T > | |
using | gf::Distance2 = Distance< T, 2 > |
A distance function for 2D vectors. More... | |
template<typename T > | |
using | gf::Distance3 = Distance< T, 3 > |
A distance function for 3D vectors. More... | |
Functions | |
template<typename T > | |
constexpr T | gf::pi () |
Templated value of \( \pi \). More... | |
template<typename T > | |
constexpr bool | gf::almostEquals (T a, T b, T epsilon=std::numeric_limits< T >::epsilon()) |
Compare two floats. More... | |
template<typename T > | |
constexpr T | gf::degreesToRadians (T degrees) |
Convert degrees to radians. More... | |
template<typename T > | |
constexpr T | gf::radiansToDegrees (T radians) |
Convert radians to degrees. More... | |
template<typename T > | |
constexpr T | gf::linearStep (T t) |
Linear step. More... | |
template<typename T > | |
constexpr T | gf::cubicStep (T t) |
Cubic step (smoothstep) More... | |
template<typename T > | |
constexpr T | gf::quinticStep (T t) |
Quintic step (smootherstep) More... | |
template<typename T > | |
T | gf::cosineStep (T t) |
Cosine step. More... | |
template<typename T , typename U > | |
constexpr T | gf::lerp (T lhs, T rhs, U t) |
Linear interpolation function. More... | |
template<typename T > | |
constexpr T | gf::clamp (T val, T lo, T hi) |
Clamping function. More... | |
template<typename T > | |
constexpr T | gf::square (T val) |
Square function. More... | |
template<typename T > | |
constexpr T | gf::cube (T val) |
Cube function. More... | |
template<typename T > | |
constexpr int | gf::sign (T val) |
Sign function. More... | |
template<typename T > | |
constexpr T | gf::absdiff (T lhs, T rhs) |
Absolute difference of two values. More... | |
Variables | |
constexpr float | gf::Pi = pi<float>() |
The \( \pi \) constant. More... | |
constexpr float | gf::Pi2 = Pi / 2 |
The \( \frac{\pi}{2} \) constant. More... | |
constexpr float | gf::Pi3 = Pi / 3 |
The \( \frac{\pi}{3} \) constant. More... | |
constexpr float | gf::Pi4 = Pi / 4 |
The \( \frac{\pi}{4} \) constant. More... | |
constexpr float | gf::Pi6 = Pi / 6 |
The \( \frac{\pi}{6} \) constant. More... | |
constexpr float | gf::Sqrt2 = 1.41421356237309504880f |
The \( \sqrt{2} \) constant. More... | |
constexpr float | gf::InvSqrt2 = 1 / Sqrt2 |
The \( \frac{1}{\sqrt{2}} \) constant. More... | |
constexpr float | gf::Sqrt3 = 1.7320508075688772935f |
The \( \sqrt{3} \) constant. More... | |
constexpr float | gf::Epsilon = std::numeric_limits<float>::epsilon() |
Machine epsilon. More... | |
Maths classes and functions.
using gf::Color3 = typedef Vector<T, 3> |
A color vector with 3 components.
using gf::Color3d = typedef Color3<double> |
A double color vector with 3 components.
using gf::Color3f = typedef Color3<float> |
A float color vector with 3 components.
using gf::Color3u = typedef Color3<uint8_t> |
A uint8_t color vector with 3 components.
using gf::Color4 = typedef Vector<T, 4> |
A color vector with 4 components.
using gf::Color4d = typedef Color4<double> |
A double color vector with 4 components.
using gf::Color4f = typedef Color4<float> |
A float color vector with 4 components.
using gf::Color4u = typedef Color4<uint8_t> |
A uint8_t color vector with 4 components.
using gf::Distance = typedef T (*)(Vector<T, N>, Vector<T, N>) |
A distance function.
A distance function is a function that gives the distance between two vectors.
using gf::Distance2 = typedef Distance<T, 2> |
A distance function for 2D vectors.
using gf::Distance3 = typedef Distance<T, 3> |
A distance function for 3D vectors.
using gf::Matrix2d = typedef Matrix<double, 2, 2> |
A double square matrix of size 2.
using gf::Matrix2f = typedef Matrix<float, 2, 2> |
A float square matrix of size 2.
using gf::Matrix3d = typedef Matrix<double, 3, 3> |
A double square matrix of size 3.
using gf::Matrix3f = typedef Matrix<float, 3, 3> |
A float square matrix of size 3.
using gf::Matrix4d = typedef Matrix<double, 4, 4> |
A double square matrix of size 4.
using gf::Matrix4f = typedef Matrix<float, 4, 4> |
A float square matrix of size 4.
using gf::RangeF = typedef Range<float> |
A float range.
using gf::RangeI = typedef Range<int> |
A int range.
using gf::RangeU = typedef Range<unsigned> |
A unsigned range.
using gf::RangeZ = typedef Range<std::size_t> |
A std::size_t
range.
using gf::Step = typedef T (*)(T) |
A step is a function with special features.
A step \( f \) is a (mathematical) function which has the following properties:
It can be used to smooth a linear interpolation.
using gf::Vector2b = typedef Vector<bool, 2> |
A bool vector with 2 components.
using gf::Vector2d = typedef Vector<double, 2> |
A double vector with 2 components.
using gf::Vector2f = typedef Vector<float, 2> |
A float vector with 2 components.
using gf::Vector2i = typedef Vector<int, 2> |
A int vector with 2 components.
using gf::Vector2u = typedef Vector<unsigned, 2> |
A unsigned vector with 2 components.
using gf::Vector2z = typedef Vector<std::size_t, 2> |
A std::size_t vector with 2 components.
using gf::Vector3b = typedef Vector<bool, 3> |
A bool vector with 3 components.
using gf::Vector3d = typedef Vector<double, 3> |
A double vector with 3 components.
using gf::Vector3f = typedef Vector<float, 3> |
A float vector with 3 components.
using gf::Vector3i = typedef Vector<int, 3> |
A int vector with 3 components.
using gf::Vector3u = typedef Vector<unsigned, 3> |
A unsigned vector with 3 components.
using gf::Vector3z = typedef Vector<std::size_t, 3> |
A std::size_t vector with 3 components.
using gf::Vector4b = typedef Vector<bool, 4> |
A bool vector with 4 components.
using gf::Vector4d = typedef Vector<double, 4> |
A double vector with 4 components.
using gf::Vector4f = typedef Vector<float, 4> |
A float vector with 4 components.
using gf::Vector4i = typedef Vector<int, 4> |
A int vector with 4 components.
using gf::Vector4u = typedef Vector<unsigned, 4> |
A unsigned vector with 4 components.
using gf::Vector4z = typedef Vector<std::size_t, 4> |
A std::size_t vector with 4 components.
|
constexpr |
Absolute difference of two values.
This function is defined as:
\[ \text{absdiff}(a, b) = | a - b | \]
lhs | The first value |
rhs | The second value |
|
constexpr |
Compare two floats.
a | The first float |
b | The second float |
epsilon | A small value that controls the equality comparison |
|
constexpr |
Clamping function.
This function takes a value and returns it if it is in a specified range. If not, the returned value is the nearest value in the range.
val | The value to clamp |
lo | The minimum accepted value |
hi | The maximum accepted value |
|
inline |
|
constexpr |
Cube function.
For a value \( x \), the cube value is \( x^3 \).
val | A value |
|
constexpr |
Cubic step (smoothstep)
\[ f(t) = -2 * t^3 + 3 * t^2 \]
Compared to a step, it has the following properties:
This function is also known as smoothstep
|
constexpr |
Convert degrees to radians.
degrees | An angle in degrees |
|
constexpr |
Linear interpolation function.
This functions returns an interpolated value between two values lhs
and rhs
according to a parameter \( t \). When \( t = 0 \) then lhs
is returned, and when \( t = 1 \) then rhs
is returned.
lhs | The first value |
rhs | The second value |
t | The interpolation parameter, generally in the interval \( [0,1] \) |
|
constexpr |
|
constexpr |
Templated value of \( \pi \).
|
constexpr |
Quintic step (smootherstep)
\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]
Compared to a step, it has the following properties:
This function is also known as smootherstep
|
constexpr |
Convert radians to degrees.
radians | An angle in radians |
|
constexpr |
Sign function.
The sign function of \( x \) is:
val | A value |
|
constexpr |
Square function.
For a value \( x \), the square value is \( x^2 \).
val | A value |
|
constexpr |
Machine epsilon.
|
constexpr |
The \( \frac{1}{\sqrt{2}} \) constant.
|
constexpr |
The \( \pi \) constant.
|
constexpr |
The \( \frac{\pi}{2} \) constant.
|
constexpr |
The \( \frac{\pi}{3} \) constant.
|
constexpr |
The \( \frac{\pi}{4} \) constant.
|
constexpr |
The \( \frac{\pi}{6} \) constant.
|
constexpr |
The \( \sqrt{2} \) constant.
|
constexpr |
The \( \sqrt{3} \) constant.