![]() |
Gamedev Framework (gf)
0.19.0
A C++17 framework for 2D games
|
Geometry classes and functions. More...
Classes | |
| struct | gf::Circ< T > |
| Utility class for manipulating circles. More... | |
| struct | gf::Penetration |
| Data about the collision between two objects. More... | |
| class | gf::Bresenham |
| State for the Bresenham's line algorithm. More... | |
| struct | gf::Segment< T > |
| A segment with two points. More... | |
| class | gf::PointSequence |
| A sequence of points. More... | |
| class | gf::Polygon |
| A convex polygon. More... | |
| class | gf::Polyline |
| A polyline. More... | |
| struct | gf::Rect< T > |
| Utility class for manipulating 2D axis aligned rectangles. More... | |
| struct | gf::Rotation |
| A rotation. More... | |
| struct | gf::Translation |
| A translation. More... | |
| struct | gf::Transform |
| A simple transformation (rotation then translation) More... | |
| class | gf::EdgeRef< T > |
| A reference to an edge (two points) More... | |
| class | gf::TriangleRef< T > |
| A reference to a triangle (three points) More... | |
Typedefs | |
| using | gf::CircF = Circ< float > |
A float circle. More... | |
| using | gf::CircD = Circ< double > |
A double circle. More... | |
| using | gf::CircI = Circ< int > |
A int circle. More... | |
| using | gf::CircU = Circ< unsigned > |
A unsigned circle. More... | |
| using | gf::CircZ = Circ< std::size_t > |
A std::size_t circle. More... | |
| using | gf::SegmentF = Segment< float > |
| A segment with float vectors. More... | |
| using | gf::SegmentD = Segment< double > |
| A segment with double vectors. More... | |
| using | gf::SegmentI = Segment< int > |
| A segment with int vectors. More... | |
| using | gf::RectF = Rect< float > |
A float rectangle. More... | |
| using | gf::RectD = Rect< double > |
A double rectangle. More... | |
| using | gf::RectI = Rect< int > |
A int rectangle. More... | |
| using | gf::RectU = Rect< unsigned > |
A unsigned rectangle. More... | |
| using | gf::RectZ = Rect< std::size_t > |
A std::size_t rectangle. More... | |
Enumerations | |
| enum | gf::Direction : int8_t { gf::Direction::Center = -1, gf::Direction::Up = 0, gf::Direction::Right = 1, gf::Direction::Down = 2, gf::Direction::Left = 3 } |
| Main four directions. More... | |
| enum | gf::Orientation : int8_t { gf::Orientation::Center = -1, gf::Orientation::North = 0, gf::Orientation::NorthEast = 1, gf::Orientation::East = 2, gf::Orientation::SouthEast = 3, gf::Orientation::South = 4, gf::Orientation::SouthWest = 5, gf::Orientation::West = 6, gf::Orientation::NorthWest = 7 } |
| Cardinal and ordinal orientation. More... | |
| enum | gf::Winding { gf::Winding::Clockwise, gf::Winding::Counterclockwise } |
| The direction of a polygon's rotation. More... | |
Functions | |
| GF_CORE_API Vector2f | gf::unit (Direction direction) |
| Get a unit vector from a direction. More... | |
| GF_CORE_API Vector2i | gf::displacement (Direction direction) |
| Get a vector from a direction. More... | |
| GF_CORE_API float | gf::angle (Direction direction) |
| Get an angle from a direction. More... | |
| GF_CORE_API Direction | gf::opposite (Direction direction) |
| Get the opposite direction. More... | |
| GF_CORE_API Direction | gf::orthogonalCW (Direction direction) |
| Get the orthogonal direction clockwise. More... | |
| GF_CORE_API Direction | gf::orthogonalCCW (Direction direction) |
| Get the orthogonal direction counter-clockwise. More... | |
| GF_CORE_API Direction | gf::nextCW (Direction direction) |
| Get the next direction clockwise. More... | |
| GF_CORE_API Direction | gf::nextCCW (Direction direction) |
| Get the next direction counter-clockwise. More... | |
| GF_CORE_API std::vector< Vector2i > | gf::generateLine (Vector2i p0, Vector2i p1) |
| Generate a line between two positions. More... | |
| GF_CORE_API Polygon | gf::convexHull (Span< const Vector2f > points) |
| Compute the convex hull of a set of points. More... | |
| GF_CORE_API std::vector< Vector2f > | gf::simplifyPoints (Span< const Vector2f > points, float distance=Epsilon) |
| Simplify a sequence of points. More... | |
| GF_CORE_API std::vector< Polyline > | gf::buildLines (Span< const SegmentI > segments) |
| Build a set of lines from a set of segments. More... | |
| GF_CORE_API Vector2f | gf::unit (Orientation orientation) |
| Get a unit vector from an orientation. More... | |
| GF_CORE_API Vector2i | gf::displacement (Orientation orientation) |
| Get a vector from an orientation. More... | |
| GF_CORE_API float | gf::angle (Orientation orientation) |
| Get an angle from a orientation. More... | |
| GF_CORE_API Orientation | gf::orientation (float angle) |
| Get an orientation from an angle. More... | |
| GF_CORE_API Orientation | gf::opposite (Orientation orientation) |
| Get the opposite orientation. More... | |
| GF_CORE_API Orientation | gf::orthogonalCW (Orientation orientation) |
| Get the orthogonal orientation clockwise. More... | |
| GF_CORE_API Orientation | gf::orthogonalCCW (Orientation orientation) |
| Get the orthogonal orientation counter-clockwise. More... | |
| GF_CORE_API Orientation | gf::nextCW (Orientation orientation) |
| Get the next orientation clockwise. More... | |
| GF_CORE_API Orientation | gf::nextCCW (Orientation orientation) |
| Get the next orientation counter-clockwise. More... | |
| template<typename T > | |
| constexpr Rect< T > | gf::computeBoxQuarter (const Rect< T > &other, Quarter quarter) |
| Divide a rectangle in quarters. More... | |
| constexpr Vector2f | gf::transform (const Matrix3f &mat, Vector2f point) |
| Apply an affine transformation to a 2D point. More... | |
| GF_CORE_API RectF | gf::transform (const Matrix3f &mat, const RectF &rect) |
| Apply an affine transformaton to a rectangle. More... | |
| constexpr Matrix3f | gf::identityTransform () |
| Identity transform. More... | |
| Matrix3f | gf::translation (Vector2f offset) |
| Get a translation matrix. More... | |
| GF_CORE_API void | gf::translate (Matrix3f &mat, Vector2f offset) |
| Combine the current transform with a translation. More... | |
| Matrix3f | gf::rotation (float angle) |
| Get a rotation matrix. More... | |
| Matrix3f | gf::rotation (float angle, Vector2f center) |
| Get a rotation matrix. More... | |
| GF_CORE_API void | gf::rotate (Matrix3f &mat, float angle) |
| Combine the current transform with a rotation. More... | |
| GF_CORE_API void | gf::rotate (Matrix3f &mat, float angle, Vector2f center) |
| Combine the current transform with a rotation. More... | |
| Matrix3f | gf::scaling (Vector2f factor) |
| Get a scaling matrix. More... | |
| Matrix3f | gf::scaling (Vector2f factor, Vector2f center) |
| Get a scaling matrix. More... | |
| GF_CORE_API void | gf::scale (Matrix3f &mat, Vector2f factor) |
| Combine the current transform with a scaling. More... | |
| GF_CORE_API void | gf::scale (Matrix3f &mat, Vector2f factor, Vector2f center) |
| Combine the current transform with a scaling. More... | |
| GF_CORE_API std::vector< TriangleRef< const Vector2f > > | gf::triangulation (Span< const Vector2f > points) |
| Compute a Delaunay triangulation of a set of points. More... | |
Geometry classes and functions.
| using gf::SegmentD = typedef Segment<double> |
A segment with double vectors.
| using gf::SegmentF = typedef Segment<float> |
A segment with float vectors.
| using gf::SegmentI = typedef Segment<int> |
A segment with int vectors.
|
strong |
Main four directions.
gf::Direction represents one of the four main directions. A special value is added to represent the center, it indicates no direction.
| Enumerator | |
|---|---|
| Center | The center, indicates no direction. |
| Up | The up direction. |
| Right | The right direction. |
| Down | The down direction. |
| Left | The left direction. |
|
strong |
Cardinal and ordinal orientation.
gf::Orientation represents one the four cardinal orientations and the four ordinal (or intercardinal) orientations. A special value is added to represent the center, it indicates no orientation.
|
strong |
| GF_CORE_API float gf::angle | ( | Direction | direction | ) |
Get an angle from a direction.
Up is at angle 0 and angle grows clockwise.
| direction | The direction |
| GF_CORE_API float gf::angle | ( | Orientation | orientation | ) |
Get an angle from a orientation.
East is at angle 0 and angle grows clockwise.
| orientation | The orientation |
Build a set of lines from a set of segments.
| segments | A set of segments |
| constexpr Rect<T> gf::computeBoxQuarter | ( | const Rect< T > & | other, |
| Quarter | quarter | ||
| ) |
Divide a rectangle in quarters.
| other | The rectangle to divide |
| quarter | The quarter to compute |
Compute the convex hull of a set of points.
This function uses the Quickhull algorithm.
Complexity: \( O(n \log n)\) on average, \( O(n^2) \) on worst case
| points | The set of points |
Get a vector from a direction.
The vector has its coordinates at -1, 0 or 1 depending on the direction. It can be used to represent the displacement on a grid in the given direction.
| direction | The direction |
| GF_CORE_API Vector2i gf::displacement | ( | Orientation | orientation | ) |
Get a vector from an orientation.
The vector has its coordinates at -1, 0 or 1 depending on the orientation. It can be used to represent the displacement on a grid in the given orientation.
| orientation | The orientation |
Generate a line between two positions.
This function uses Bresenham's line algorithm.
| p0 | The first point of the line |
| p1 | The last point of the line |
| constexpr Matrix3f gf::identityTransform | ( | ) |
Identity transform.
Get the next direction counter-clockwise.
| direction | The direction |
| GF_CORE_API Orientation gf::nextCCW | ( | Orientation | orientation | ) |
Get the next orientation counter-clockwise.
| orientation | The orientation |
Get the next direction clockwise.
| direction | The direction |
| GF_CORE_API Orientation gf::nextCW | ( | Orientation | orientation | ) |
Get the next orientation clockwise.
| orientation | The orientation |
Get the opposite direction.
| direction | The direction |
| GF_CORE_API Orientation gf::opposite | ( | Orientation | orientation | ) |
Get the opposite orientation.
| orientation | The orientation |
| GF_CORE_API Orientation gf::orientation | ( | float | angle | ) |
Get an orientation from an angle.
East is at angle 0 and angle grows clockwise.
| angle | The angle |
Get the orthogonal direction counter-clockwise.
| direction | The direction |
| GF_CORE_API Orientation gf::orthogonalCCW | ( | Orientation | orientation | ) |
Get the orthogonal orientation counter-clockwise.
| orientation | The orientation |
Get the orthogonal direction clockwise.
| direction | The direction |
| GF_CORE_API Orientation gf::orthogonalCW | ( | Orientation | orientation | ) |
Get the orthogonal orientation clockwise.
| orientation | The orientation |
| GF_CORE_API void gf::rotate | ( | Matrix3f & | mat, |
| float | angle | ||
| ) |
Combine the current transform with a rotation.
| mat | The current transform |
| angle | The angle of the rotation (in radians) |
Combine the current transform with a rotation.
| mat | The current transform |
| angle | The angle of the rotation (in radians) |
| center | The center of the rotation |
|
inline |
Get a rotation matrix.
| angle | The angle of the rotation (in radians) |
angle radians Get a rotation matrix.
| angle | The angle of the rotation (in radians) |
| center | The center of the rotation |
angle radians of origin center Combine the current transform with a scaling.
| mat | The current transform |
| factor | The scaling factor |
Combine the current transform with a scaling.
| mat | The current transform |
| factor | The scaling factor |
| center | The center of the scaling |
Get a scaling matrix.
| factor | The scaling factor |
factor Get a scaling matrix.
| factor | The scaling factor |
| center | The center of the scaling |
factor of origin center | GF_CORE_API std::vector<Vector2f> gf::simplifyPoints | ( | Span< const Vector2f > | points, |
| float | distance = Epsilon |
||
| ) |
Simplify a sequence of points.
This function uses the Douglas–Peucker algorithm.
| points | The sequence of points |
| distance | The maximum authorized distance between the original points and the simplified points |
Apply an affine transformation to a 2D point.
| mat | The transformation matrix |
| point | The point to transform |
Apply an affine transformaton to a rectangle.
The resulting rectangle is axis-aligned
| mat | The transformation matrix |
| rect | The rectangle to transform |
Combine the current transform with a translation.
| mat | The current transform |
| offset | The offset of the translation |
Get a translation matrix.
| offset | The offset of the translation |
offset | GF_CORE_API std::vector<TriangleRef<const Vector2f> > gf::triangulation | ( | Span< const Vector2f > | points | ) |
Compute a Delaunay triangulation of a set of points.
| points | The set of points |
Get a unit vector from a direction.
| direction | The direction |
| GF_CORE_API Vector2f gf::unit | ( | Orientation | orientation | ) |
Get a unit vector from an orientation.
| orientation | The orientation |
1.8.13