#include <recti/polygon.hpp>
template<typename T>
Polygon class
Template parameters | |
---|---|
T |
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.
Constructors, destructors, conversion operators
Public functions
- auto operator+=(const Vector2<T>& rhs) -> Polygon & -> auto constexpr
- Adds a vector to the origin of the polygon, effectively translating the polygon.
- auto signed_area_x2() const -> T -> auto constexpr
- Calculates the signed area of the polygon multiplied by 2.
- auto lb() const -> Point< T > -> auto
- auto ub() const -> Point< T > -> auto
Function documentation
template<typename T>
recti:: Polygon<T>:: Polygon(gsl::span<const Point<T>> pointset) explicit constexpr
Constructs a new Polygon object from a set of points.
Parameters | |
---|---|
pointset in | A span of points representing the vertices of the polygon. |
This constructor takes a gsl::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.
template<typename T>
auto recti:: Polygon<T>:: operator+=(const Vector2<T>& rhs) -> Polygon & constexpr
Adds a vector to the origin of the polygon, effectively translating the polygon.
Parameters | |
---|---|
rhs in | The vector to add to the origin. |
Returns | A reference to the modified polygon. |
template<typename T>
auto recti:: Polygon<T>:: signed_area_x2() const -> T constexpr
Calculates the signed area of the polygon multiplied by 2.
Returns | 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.