![]() |
Gamedev Framework (gf)
0.19.0
A C++17 framework for 2D games
|
gf provides a generic gf::Vector type and a generic gf::Matrix type that are used throughout the library.
A gf::Vector represents a mathematical vector in a \( N \)-dimensional space. It has a broad range of applications. The most obvious is to represent the position of an object in the world space but it's not the only one.
The gf::Vector type is totally generic regarding its type but also its dimension \( N \).
gf defines common mathematical operators for two vectors but also for a vector and a scalar. In each case, type conversion is made if necessary, following the usual rules of the language. The following table gives the semantics of the main operations between two vectors \( \mathbf{a} \) and \( \mathbf{b} \), or between a vector \( \mathbf{a} \) and a scalar \( \lambda \). These operations are all defined component-wise.
\( \bullet \) | \( \mathbf{a} \bullet \mathbf{b} \) | \( \mathbf{a} \bullet \lambda \) | \( \lambda \bullet \mathbf{a} \) |
---|---|---|---|
\( + \) | \( a_i + b_i \) | \( a_i + \lambda \) | \( \lambda + a_i \) |
\( - \) | \( a_i - b_i \) | \( a_i - \lambda \) | \( \lambda - a_i \) |
\( * \) | \( a_i * b_i \) | \( a_i * \lambda \) | \( \lambda * a_i \) |
\( / \) | \( a_i / b_i \) | \( a_i / \lambda \) | \( \lambda / a_i \) |
gf also defines equality and inequality operators for vectors.
A simple transformation in gf is a rotation followed by a translation. A simple rotation is represented by the gf::Rotation type, a simple translation is represented by the gf::Translation type, and the simple transformation is represented by the gf::Transform type.
These simple transformations are useful in the physics engine.
You can define a generic affine transformation in 2D with a transformation matrix thanks to the gf::Matrix3f type.