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

Represents a 2D segment (technically a polygon_shape). More...

#include <segment.h>

Public Types

using tvec
using value_type

Public Member Functions

constexpr tsegment (tvec const &start, tvec const &end) noexcept
constexpr tsegment (std::pair< tvec, tvec > const &p) noexcept
constexpr tvec vec () const noexcept
tvec dir () const noexcept
auto length () const noexcept
constexpr auto center () const noexcept
basic_line_t< T > line () const noexcept
tsegment & set_position (tvec const &pos) noexcept
tsegment & operator+= (tvec const &offs) noexcept
tsegment & operator-= (tvec const &offs) noexcept
tsegment & translate (tvec const &offs) noexcept
tsegment & set_length (T len) noexcept
tsegment & set_length_around_center (T len) noexcept
tsegment & grow (T len) noexcept
tsegment & shrink (T len) noexcept
constexpr std::optional< tvec > intersection (tsegment const &other) const noexcept
T edge_length () const
 Shape interface.
tvec edge_point_alpha (T t) const
tvec edge_point (T t) const
trec2< T > bounding_box () const
tvec closest_point_to (tvec pt) const
interval< T > projected_on_axis (tvec const &axis) const
template<typename FUNC>
void for_each_edge (FUNC &&func) const
 Polygon shape interface.
template<typename FUNC>
void for_each_vertex (FUNC &&func) const
size_t vertex_count () const
size_t edge_count () const
auto edge (size_t index) const -> std::optional< std::pair< glm::tvec2< T >, glm::tvec2< T > > >
auto vertex (size_t index) const -> std::optional< tvec >

Static Public Member Functions

static constexpr tsegment from_offset (tvec const &start, tvec const &offset) noexcept
static constexpr tsegment from_dir (tvec const &start, tvec const &dir, T len) noexcept
static constexpr tsegment from_pair (std::pair< tvec, tvec > const &p) noexcept

Public Attributes

tvec start
tvec end

Detailed Description

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

Represents a 2D segment (technically a polygon_shape).

Definition at line 14 of file segment.h.

Member Typedef Documentation

◆ tvec

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

Definition at line 16 of file segment.h.

◆ value_type

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

Definition at line 17 of file segment.h.

Constructor & Destructor Documentation

◆ tsegment() [1/2]

template<std::floating_point T>
ghassanpl::geometry::tsegment< T >::tsegment ( tvec const & start,
tvec const & end )
inlineconstexprnoexcept

Definition at line 23 of file segment.h.

◆ tsegment() [2/2]

template<std::floating_point T>
ghassanpl::geometry::tsegment< T >::tsegment ( std::pair< tvec, tvec > const & p)
inlineconstexprnoexcept

Definition at line 24 of file segment.h.

Member Function Documentation

◆ bounding_box()

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

Definition at line 87 of file segment.h.

◆ center()

template<std::floating_point T>
auto ghassanpl::geometry::tsegment< T >::center ( ) const
inlineconstexprnoexcept

Definition at line 29 of file segment.h.

◆ closest_point_to()

template<std::floating_point T>
tvec ghassanpl::geometry::tsegment< T >::closest_point_to ( tvec pt) const
inline

Definition at line 88 of file segment.h.

◆ dir()

template<std::floating_point T>
tvec ghassanpl::geometry::tsegment< T >::dir ( ) const
inlinenoexcept

Definition at line 27 of file segment.h.

◆ edge()

template<std::floating_point T>
auto ghassanpl::geometry::tsegment< T >::edge ( size_t index) const -> std::optional< std::pair< glm::tvec2< T >, glm::tvec2< T > > >
inline

Definition at line 126 of file segment.h.

◆ edge_count()

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

Definition at line 124 of file segment.h.

◆ edge_length()

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

Shape interface.

Definition at line 84 of file segment.h.

◆ edge_point()

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

Definition at line 86 of file segment.h.

◆ edge_point_alpha()

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

Definition at line 85 of file segment.h.

◆ for_each_edge()

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

Polygon shape interface.

Definition at line 110 of file segment.h.

◆ for_each_vertex()

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

Definition at line 116 of file segment.h.

◆ from_dir()

template<std::floating_point T>
constexpr tsegment ghassanpl::geometry::tsegment< T >::from_dir ( tvec const & start,
tvec const & dir,
T len )
inlinestaticconstexprnoexcept

Definition at line 32 of file segment.h.

◆ from_offset()

template<std::floating_point T>
constexpr tsegment ghassanpl::geometry::tsegment< T >::from_offset ( tvec const & start,
tvec const & offset )
inlinestaticconstexprnoexcept

Definition at line 31 of file segment.h.

◆ from_pair()

template<std::floating_point T>
constexpr tsegment ghassanpl::geometry::tsegment< T >::from_pair ( std::pair< tvec, tvec > const & p)
inlinestaticconstexprnoexcept

Definition at line 33 of file segment.h.

◆ grow()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::grow ( T len)
inlinenoexcept

Definition at line 53 of file segment.h.

◆ intersection()

template<std::floating_point T>
std::optional< tvec > ghassanpl::geometry::tsegment< T >::intersection ( tsegment< T > const & other) const
inlineconstexprnoexcept

Definition at line 56 of file segment.h.

◆ length()

template<std::floating_point T>
auto ghassanpl::geometry::tsegment< T >::length ( ) const
inlinenoexcept

Definition at line 28 of file segment.h.

◆ line()

template<std::floating_point T>
basic_line_t< T > ghassanpl::geometry::tsegment< T >::line ( ) const
inlinenoexcept

Definition at line 35 of file segment.h.

◆ operator+=()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::operator+= ( tvec const & offs)
inlinenoexcept

Definition at line 38 of file segment.h.

◆ operator-=()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::operator-= ( tvec const & offs)
inlinenoexcept

Definition at line 39 of file segment.h.

◆ projected_on_axis()

template<std::floating_point T>
interval< T > ghassanpl::geometry::tsegment< T >::projected_on_axis ( tvec const & axis) const
inline

Definition at line 100 of file segment.h.

◆ set_length()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::set_length ( T len)
inlinenoexcept

Definition at line 42 of file segment.h.

◆ set_length_around_center()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::set_length_around_center ( T len)
inlinenoexcept

Definition at line 43 of file segment.h.

◆ set_position()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::set_position ( tvec const & pos)
inlinenoexcept

Definition at line 37 of file segment.h.

◆ shrink()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::shrink ( T len)
inlinenoexcept

Definition at line 54 of file segment.h.

◆ translate()

template<std::floating_point T>
tsegment & ghassanpl::geometry::tsegment< T >::translate ( tvec const & offs)
inlinenoexcept

Definition at line 40 of file segment.h.

◆ vec()

template<std::floating_point T>
tvec ghassanpl::geometry::tsegment< T >::vec ( ) const
inlineconstexprnoexcept

Definition at line 26 of file segment.h.

◆ vertex()

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

Definition at line 133 of file segment.h.

◆ vertex_count()

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

Definition at line 122 of file segment.h.

Member Data Documentation

◆ end

template<std::floating_point T>
tvec ghassanpl::geometry::tsegment< T >::end

Definition at line 20 of file segment.h.

◆ start

template<std::floating_point T>
tvec ghassanpl::geometry::tsegment< T >::start

Definition at line 19 of file segment.h.