codac 1.5.6
Loading...
Searching...
No Matches
codac2::Polygon Class Reference

Represents a polygon (convex or non-convex) defined by its vertices enclosed in IntervalVectors. More...

#include <codac2_Polygon.h>

Inheritance diagram for codac2::Polygon:

Public Member Functions

 Polygon (std::initializer_list< Vector > vertices)
 Constructs a Polygon from an initializer list of Vector vertices.
 
 Polygon (const std::vector< Vector > &vertices)
 Constructs a Polygon from a vector of Vector vertices.
 
 Polygon (const std::vector< IntervalVector > &vertices)
 Constructs a Polygon from a vector of IntervalVector vertices.
 
 Polygon (std::initializer_list< Segment > edges)
 Constructs a Polygon from an initializer list of Segment edges.
 
 Polygon (const std::vector< Segment > &edges)
 Constructs a Polygon from a vector of Segment edges.
 
 Polygon (const IntervalVector &x)
 Constructs a box as a Polygon.
 
const std::vector< Segment > & edges () const
 Returns the list of edges of the polygon.
 
std::list< IntervalVector > unsorted_vertices () const
 Returns the list of unique vertices in no particular order.
 
std::vector< IntervalVector > sorted_vertices () const
 Returns the list of vertices sorted in polygonal order.
 
bool is_empty () const
 Checks whether the polygon is empty (has no vertex).
 
BoolInterval contains (const IntervalVector &p) const
 Checks whether the polygon contains a given point.
 
bool operator== (const Polygon &p) const
 Comparison operator.
 

Static Public Member Functions

static Polygon empty ()
 Provides an empty polygon.
 

Protected Member Functions

 Polygon ()
 Default protected constructor used internally.
 

Protected Attributes

const std::vector< Segment_edges
 Internal representation of the polygon as a list of edges.
 

Detailed Description

Represents a polygon (convex or non-convex) defined by its vertices enclosed in IntervalVectors.

A polygon can be constructed from a list of vertices (either Vector or IntervalVector) or from a list of edges (Segments). Internally, it stores a list of edges enclosed in Segments.

Constructor & Destructor Documentation

◆ Polygon() [1/6]

codac2::Polygon::Polygon ( std::initializer_list< Vector > vertices)

Constructs a Polygon from an initializer list of Vector vertices.

Parameters
verticesA list of vertices defining the polygon.

◆ Polygon() [2/6]

codac2::Polygon::Polygon ( const std::vector< Vector > & vertices)

Constructs a Polygon from a vector of Vector vertices.

Parameters
verticesA vector of vertices defining the polygon.

◆ Polygon() [3/6]

codac2::Polygon::Polygon ( const std::vector< IntervalVector > & vertices)
explicit

Constructs a Polygon from a vector of IntervalVector vertices.

Parameters
verticesA vector of IntervalVectors enclosing the polygon vertices.

◆ Polygon() [4/6]

codac2::Polygon::Polygon ( std::initializer_list< Segment > edges)

Constructs a Polygon from an initializer list of Segment edges.

Parameters
edgesA list of Segments forming the polygon.

◆ Polygon() [5/6]

codac2::Polygon::Polygon ( const std::vector< Segment > & edges)

Constructs a Polygon from a vector of Segment edges.

Parameters
edgesA vector of Segments forming the polygon.

◆ Polygon() [6/6]

codac2::Polygon::Polygon ( const IntervalVector & x)
explicit

Constructs a box as a Polygon.

Typically used to create a rectangular polygon.

Parameters
xAn IntervalVector representing the bounds of the polygon.

Member Function Documentation

◆ edges()

const std::vector< Segment > & codac2::Polygon::edges ( ) const

Returns the list of edges of the polygon.

Returns
A constant reference to the vector of Segments.

◆ unsorted_vertices()

std::list< IntervalVector > codac2::Polygon::unsorted_vertices ( ) const

Returns the list of unique vertices in no particular order.

If a vertex is involved several times in the polygon definition, then it will be returned only once in the output list.

Returns
A list of IntervalVectors enclosing the unique vertices.

◆ sorted_vertices()

std::vector< IntervalVector > codac2::Polygon::sorted_vertices ( ) const

Returns the list of vertices sorted in polygonal order.

Returns
A vector of IntervalVectors enclosing the ordered vertices.

◆ is_empty()

bool codac2::Polygon::is_empty ( ) const

Checks whether the polygon is empty (has no vertex).

Returns
True if the polygon is empty.

◆ contains()

BoolInterval codac2::Polygon::contains ( const IntervalVector & p) const

Checks whether the polygon contains a given point.

Parameters
pThe point to check, enclosed in an IntervalVector.
Returns
A BoolInterval indicating possible containment.

◆ operator==()

bool codac2::Polygon::operator== ( const Polygon & p) const

Comparison operator.

Equality means that both polygons have the same edges, possibly in a different order (clockwise or counterclockwise).

Parameters
pAnother polygon.
Returns
True if both polygons are strictly equal.

◆ empty()

static Polygon codac2::Polygon::empty ( )
static

Provides an empty polygon.

Returns
An empty polygon without vertices.

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