header_utils
Loading...
Searching...
No Matches
ghassanpl::geometry::tpolygon< T > Struct Template Reference

Represents a 2D polygon polygon_shape. More...

#include <polygon.h>

Public Types

using tvec
using value_type

Public Member Functions

tvec & operator[] (size_t index)
tvec const & operator[] (size_t index) const
auto cbegin () const
auto cend () const
auto begin ()
auto end ()
auto begin () const
auto end () const
auto size () const
bool is_valid () const noexcept
tpolygon< T > convex_hull () const noexcept
size_t vertex_count () const
size_t edge_count () const
std::optional< std::pair< tvec, tvec > > edge (size_t index) const
std::optional< tvec > vertex (size_t index) const
template<typename FUNC>
void for_each_vertex (FUNC &&func) const
template<typename FUNC>
void for_each_edge (FUNC &&func) const
std::vector< tsegment< T > > edges () const noexcept
std::vector< T > interior_angles () const noexcept
T edge_length () const
tvec edge_point (T t) const
tvec edge_point_alpha (T t) const
tvec closest_point_to (tvec pt) const
T calculate_area () const
tvec centroid () const
trec2< T > bounding_box () const
bool contains (tvec test) const
 Assumes a simple polygon.

Static Public Member Functions

template<typename... ARGS>
static tpolygon from_vertices (ARGS &&... args)
template<typename S>
static tpolygon from_shape (S const &shape)

Public Attributes

std::vector< glm::tvec2< T > > vertices

Detailed Description

template<std::floating_point T>
struct ghassanpl::geometry::tpolygon< T >

Represents a 2D polygon polygon_shape.

Definition at line 42 of file polygon.h.

Member Typedef Documentation

◆ tvec

template<std::floating_point T>
using ghassanpl::geometry::tpolygon< T >::tvec

Definition at line 44 of file polygon.h.

◆ value_type

template<std::floating_point T>
using ghassanpl::geometry::tpolygon< T >::value_type

Definition at line 45 of file polygon.h.

Member Function Documentation

◆ begin() [1/2]

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::begin ( )
inline

Definition at line 70 of file polygon.h.

◆ begin() [2/2]

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::begin ( ) const
inline

Definition at line 72 of file polygon.h.

◆ bounding_box()

template<std::floating_point T>
trec2< T > ghassanpl::geometry::tpolygon< T >::bounding_box ( ) const
inline

Definition at line 248 of file polygon.h.

◆ calculate_area()

template<std::floating_point T>
T ghassanpl::geometry::tpolygon< T >::calculate_area ( ) const
inline

Definition at line 219 of file polygon.h.

◆ cbegin()

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::cbegin ( ) const
inline

Definition at line 68 of file polygon.h.

◆ cend()

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::cend ( ) const
inline

Definition at line 69 of file polygon.h.

◆ centroid()

template<std::floating_point T>
tvec ghassanpl::geometry::tpolygon< T >::centroid ( ) const
inline

Definition at line 228 of file polygon.h.

◆ contains()

template<std::floating_point T>
bool ghassanpl::geometry::tpolygon< T >::contains ( tvec test) const
inline

Assumes a simple polygon.

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Definition at line 259 of file polygon.h.

◆ edge()

template<std::floating_point T>
std::optional< std::pair< tvec, tvec > > ghassanpl::geometry::tpolygon< T >::edge ( size_t index) const
inline

Definition at line 148 of file polygon.h.

◆ edge_count()

template<std::floating_point T>
size_t ghassanpl::geometry::tpolygon< T >::edge_count ( ) const
inline

Definition at line 146 of file polygon.h.

◆ edge_length()

template<std::floating_point T>
T ghassanpl::geometry::tpolygon< T >::edge_length ( ) const
inline

Definition at line 196 of file polygon.h.

◆ edge_point()

template<std::floating_point T>
tvec ghassanpl::geometry::tpolygon< T >::edge_point ( T t) const
inline

Definition at line 205 of file polygon.h.

◆ edge_point_alpha()

template<std::floating_point T>
tvec ghassanpl::geometry::tpolygon< T >::edge_point_alpha ( T t) const
inline

Definition at line 211 of file polygon.h.

◆ edges()

template<std::floating_point T>
std::vector< tsegment< T > > ghassanpl::geometry::tpolygon< T >::edges ( ) const
inlinenoexcept

Definition at line 187 of file polygon.h.

◆ end() [1/2]

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::end ( )
inline

Definition at line 71 of file polygon.h.

◆ end() [2/2]

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::end ( ) const
inline

Definition at line 73 of file polygon.h.

◆ for_each_edge()

template<std::floating_point T>
template<typename FUNC>
void ghassanpl::geometry::tpolygon< T >::for_each_edge ( FUNC && func) const
inline

Definition at line 170 of file polygon.h.

◆ for_each_vertex()

template<std::floating_point T>
template<typename FUNC>
void ghassanpl::geometry::tpolygon< T >::for_each_vertex ( FUNC && func) const
inline

Definition at line 163 of file polygon.h.

◆ from_shape()

template<std::floating_point T>
template<typename S>
tpolygon ghassanpl::geometry::tpolygon< T >::from_shape ( S const & shape)
inlinestatic

Definition at line 56 of file polygon.h.

◆ from_vertices()

template<std::floating_point T>
template<typename... ARGS>
tpolygon ghassanpl::geometry::tpolygon< T >::from_vertices ( ARGS &&... args)
inlinestatic

Definition at line 50 of file polygon.h.

◆ is_valid()

template<std::floating_point T>
bool ghassanpl::geometry::tpolygon< T >::is_valid ( ) const
inlinenoexcept

Definition at line 76 of file polygon.h.

◆ operator[]() [1/2]

template<std::floating_point T>
tvec & ghassanpl::geometry::tpolygon< T >::operator[] ( size_t index)
inline

Definition at line 65 of file polygon.h.

◆ operator[]() [2/2]

template<std::floating_point T>
tvec const & ghassanpl::geometry::tpolygon< T >::operator[] ( size_t index) const
inline

Definition at line 66 of file polygon.h.

◆ size()

template<std::floating_point T>
auto ghassanpl::geometry::tpolygon< T >::size ( ) const
inline

Definition at line 74 of file polygon.h.

◆ vertex()

template<std::floating_point T>
std::optional< tvec > ghassanpl::geometry::tpolygon< T >::vertex ( size_t index) const
inline

Definition at line 155 of file polygon.h.

◆ vertex_count()

template<std::floating_point T>
size_t ghassanpl::geometry::tpolygon< T >::vertex_count ( ) const
inline

Definition at line 145 of file polygon.h.

Member Data Documentation

◆ vertices

template<std::floating_point T>
std::vector<glm::tvec2<T> > ghassanpl::geometry::tpolygon< T >::vertices

Definition at line 47 of file polygon.h.