|
Recti 1.2.4
|
#include <polygon.hpp>
Public Member Functions | |
| constexpr | Polygon ()=default |
| Default constructor. | |
| constexpr | Polygon (Point< T > origin, std::vector< Vector2< T > > vecs) |
| Constructs a new Polygon object from origin and vectors. | |
| constexpr | Polygon (std::span< const Point< T > > pointset) |
| Constructs a new Polygon object from a set of points. | |
| constexpr bool | operator== (const Polygon &rhs) const |
| Equality comparison operator. | |
| constexpr bool | operator!= (const Polygon &rhs) const |
| Inequality comparison operator. | |
| constexpr auto | operator+= (const Vector2< T > &rhs) -> Polygon & |
| Adds a vector to the origin of the polygon, effectively translating the polygon. | |
| constexpr auto | operator-= (const Vector2< T > &rhs) -> Polygon & |
| Subtracts a vector from the origin of the polygon, effectively translating the polygon. | |
| constexpr auto | signed_area_x2 () const -> T |
| Calculates the signed area of the polygon multiplied by 2. | |
| constexpr const Point< T > & | origin () const |
| Gets the origin point of the polygon. | |
| constexpr const std::vector< Vector2< T > > & | vectors () const |
| Gets the displacement vectors of the polygon. | |
| constexpr auto | vertices () const -> std::vector< Point< T > > |
| Gets all vertices of the polygon as points. | |
| constexpr auto | is_rectilinear () const -> bool |
| Checks if the polygon is rectilinear. | |
| constexpr auto | is_convex () const -> bool |
| Checks if the polygon is convex. | |
Polygon is a class template that represents an arbitrary polygon. It stores the origin point and a vector of edges that define the polygon. The template parameter T specifies the type of the coordinates of the points.
| T |
|
constexprdefault |
Default constructor.
|
inlineconstexpr |
Constructs a new Polygon object from origin and vectors.
| [in] | origin | The origin point of the polygon |
| [in] | vecs | Vector of displacement vectors from origin |
|
inlineexplicitconstexpr |
Constructs a new Polygon object from a set of points.
This constructor takes a std::span of Point<T> objects representing the vertices of the polygon. The first point in the span is used as the origin of the polygon, and the remaining points are used to construct the edges of the polygon as vectors relative to the origin.
| [in] | pointset | A span of points representing the vertices of the polygon. |
|
inlineconstexpr |
Checks if the polygon is convex.
A polygon is convex if all its interior angles are less than or equal to 180 degrees.
|
inlineconstexpr |
Checks if the polygon is rectilinear.
A polygon is rectilinear if all its edges are either horizontal or vertical.
|
inlineconstexpr |
Inequality comparison operator.
|
inlineconstexpr |
Adds a vector to the origin of the polygon, effectively translating the polygon.
| [in] | rhs | The vector to add to the origin. |
|
inlineconstexpr |
Subtracts a vector from the origin of the polygon, effectively translating the polygon.
| [in] | rhs | The vector to subtract from the origin. |
|
inlineconstexpr |
Equality comparison operator.
|
inlineconstexpr |
Gets the origin point of the polygon.
|
inlineconstexpr |
Calculates the signed area of the polygon multiplied by 2.
This function calculates the signed area of the polygon by summing the cross products of adjacent edges. The result is multiplied by 2 to avoid the need for floating-point arithmetic.
|
inlineconstexpr |
Gets the displacement vectors of the polygon.
|
inlineconstexpr |
Gets all vertices of the polygon as points.