Recti 1.2.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
recti::RPolygon< T > Class Template Reference

#include <rpolygon.hpp>

Public Types

using const_iterator = RPolygonVertexIterator< T >
 

Public Member Functions

constexpr RPolygon ()=default
 Default constructor.
 
constexpr auto begin () const -> const_iterator
 Iterator to first vertex (the origin).
 
constexpr auto end () const -> const_iterator
 Past-the-end iterator.
 
constexpr RPolygon (Point< T > origin, std::vector< Vector2< T > > vecs)
 Constructs a new RPolygon object from origin and vectors.
 
constexpr RPolygon (std::span< const Point< T > > pointset)
 Constructs a new RPolygon object from a set of points.
 
constexpr bool operator== (const RPolygon &rhs) const
 Equality comparison operator.
 
constexpr bool operator!= (const RPolygon &rhs) const
 Inequality comparison operator.
 
constexpr auto operator+= (const Vector2< T > &vector_offset) -> RPolygon &
 Adds a vector to the origin of the rectilinear polygon.
 
constexpr auto operator-= (const Vector2< T > &vector_offset) -> RPolygon &
 Subtracts a vector from the origin of the rectilinear polygon.
 
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 signed_area () const -> T
 Calculates the signed area of the rectilinear polygon.
 
constexpr auto is_rectilinear () const -> bool
 Checks if the polygon is rectilinear (all edges are horizontal or vertical)
 

Member Typedef Documentation

◆ const_iterator

template<typename T >
using recti::RPolygon< T >::const_iterator = RPolygonVertexIterator<T>

Constructor & Destructor Documentation

◆ RPolygon() [1/3]

template<typename T >
constexpr recti::RPolygon< T >::RPolygon ( )
constexprdefault

Default constructor.

◆ RPolygon() [2/3]

template<typename T >
constexpr recti::RPolygon< T >::RPolygon ( Point< T >  origin,
std::vector< Vector2< T > >  vecs 
)
inlineconstexpr

Constructs a new RPolygon object from origin and vectors.

Parameters
[in]originThe origin point of the polygon
[in]vecsVector of displacement vectors from origin

◆ RPolygon() [3/3]

template<typename T >
constexpr recti::RPolygon< T >::RPolygon ( std::span< const Point< T > >  pointset)
inlineexplicitconstexpr

Constructs a new RPolygon object from a set of points.

This constructor takes a std::span of Point<T> objects representing the vertices of the rectilinear polygon. The first point in the span is used as the origin of the polygon, and the remaining points are used to construct the vectors that define the edges of the polygon.

Parameters
[in]pointsetA span of Point<T> objects representing the vertices of the rectilinear polygon.

Member Function Documentation

◆ begin()

template<typename T >
constexpr auto recti::RPolygon< T >::begin ( ) const -> const_iterator
inlineconstexpr

Iterator to first vertex (the origin).

◆ end()

template<typename T >
constexpr auto recti::RPolygon< T >::end ( ) const -> const_iterator
inlineconstexpr

Past-the-end iterator.

◆ is_rectilinear()

template<typename T >
constexpr auto recti::RPolygon< T >::is_rectilinear ( ) const -> bool
inlineconstexpr

Checks if the polygon is rectilinear (all edges are horizontal or vertical)

◆ operator!=()

template<typename T >
constexpr bool recti::RPolygon< T >::operator!= ( const RPolygon< T > &  rhs) const
inlineconstexpr

Inequality comparison operator.

◆ operator+=()

template<typename T >
constexpr auto recti::RPolygon< T >::operator+= ( const Vector2< T > &  vector_offset) -> RPolygon&
inlineconstexpr

Adds a vector to the origin of the rectilinear polygon.

This method adds the given vector to the origin point of the rectilinear polygon, effectively translating the entire polygon by the specified vector.

Parameters
[in]vector_offsetThe vector to add to the origin.
Returns
A reference to the modified RPolygon object.

◆ operator-=()

template<typename T >
constexpr auto recti::RPolygon< T >::operator-= ( const Vector2< T > &  vector_offset) -> RPolygon&
inlineconstexpr

Subtracts a vector from the origin of the rectilinear polygon.

This method subtracts the given vector from the origin point of the rectilinear polygon, effectively translating the entire polygon by the negative of the specified vector.

Parameters
[in]vector_offsetThe vector to subtract from the origin.
Returns
A reference to the modified RPolygon object.

◆ operator==()

template<typename T >
constexpr bool recti::RPolygon< T >::operator== ( const RPolygon< T > &  rhs) const
inlineconstexpr

Equality comparison operator.

◆ origin()

template<typename T >
constexpr const Point< T > & recti::RPolygon< T >::origin ( ) const
inlineconstexpr

Gets the origin point of the polygon.

◆ signed_area()

template<typename T >
constexpr auto recti::RPolygon< T >::signed_area ( ) const -> T
inlineconstexpr

Calculates the signed area of the rectilinear polygon.

This method calculates the signed area of the rectilinear polygon represented by this RPolygon object using the shoelace formula.

Returns
The signed area of the rectilinear polygon.

◆ vectors()

template<typename T >
constexpr const std::vector< Vector2< T > > & recti::RPolygon< T >::vectors ( ) const
inlineconstexpr

Gets the displacement vectors of the polygon.

◆ vertices()

template<typename T >
constexpr auto recti::RPolygon< T >::vertices ( ) const -> std::vector<Point<T>>
inlineconstexpr

Gets all vertices of the polygon as points.


The documentation for this class was generated from the following file: