A convex polygon.
More...
#include <gf/Polygon.h>
◆ Polygon() [1/3]
◆ Polygon() [2/3]
Constructor from an array.
- Parameters
-
points | The array of points |
◆ Polygon() [3/3]
template<typename Iterator >
gf::Polygon::Polygon |
( |
Iterator |
first, |
|
|
Iterator |
last |
|
) |
| |
|
inline |
Constructor from points.
- Parameters
-
first | Iterator to the first point |
last | Iterator after the last point |
◆ addPoint()
void gf::Polygon::addPoint |
( |
Vector2f |
point | ) |
|
Add a point to the polygon.
- Parameters
-
point | The point to add to the polygon |
◆ applyTransform()
void gf::Polygon::applyTransform |
( |
const Matrix3f & |
mat | ) |
|
Apply a transformation to the polygon.
- Parameters
-
mat | The transformation matrix |
◆ begin()
const Vector2f* gf::Polygon::begin |
( |
| ) |
const |
Get an iterator to the first point.
- Returns
- A pointer to the first point
- See also
- end()
◆ contains()
bool gf::Polygon::contains |
( |
Vector2f |
point | ) |
const |
◆ end()
const Vector2f* gf::Polygon::end |
( |
| ) |
const |
Get an iterator past the last point.
- Returns
- A pointer past the last point
- See also
- begin()
◆ getArea()
float gf::Polygon::getArea |
( |
| ) |
const |
Compute the area of the polygon.
Complexity: \( O(n) \)
- Returns
- The area of the polygon
◆ getCenter()
Vector2f gf::Polygon::getCenter |
( |
| ) |
const |
Get the center of the polygon.
As the polygon is convex, the center is inside the polygon
- Returns
- The center of the polygon
◆ getPoint()
Vector2f gf::Polygon::getPoint |
( |
std::size_t |
index | ) |
const |
Get the i-th point of the polygon.
- Parameters
-
index | The index of the point |
◆ getPointCount()
std::size_t gf::Polygon::getPointCount |
( |
| ) |
const |
Get the number of points of the polygon.
- Returns
- The number of points of the polygon
◆ getSupport() [1/2]
Get the farthest point in a direction.
- Parameters
-
direction | The direction to search (in world coordinates) |
transform | The transformation of the polygon |
- Returns
- The farthest point of the polygon in the given direction
◆ getSupport() [2/2]
Get the farthest point in a direction.
- Parameters
-
direction | The direction to search |
- Returns
- The farthest point of the polygon in the given direction
◆ getWinding()
Winding gf::Polygon::getWinding |
( |
| ) |
const |
◆ isConvex()
bool gf::Polygon::isConvex |
( |
| ) |
const |
Check if the polygon is convex.
This function should return true, otherwise you may have problems in other functions which assume that the polygon is convex.
This function does not handle self-intersecting polygons (yet).
- Returns
- True if the polygon is convex
◆ isEmpty()
bool gf::Polygon::isEmpty |
( |
| ) |
const |
Check if the polygon is empty.
An empty polygon has no points.
- Returns
- True if the polygon is empty
◆ simplify()
void gf::Polygon::simplify |
( |
float |
distance = Epsilon | ) |
|
Simplify the polygon.
- Parameters
-
distance | The maximum authorized distance between the original points and the simplified points |