header_utils
Loading...
Searching...
No Matches
ghassanpl::geometry Namespace Reference

Namespaces

namespace  hexes
namespace  squares

Classes

struct  tcapsule
 Represents a 2D capsule area_shape. More...
struct  tcircle
 Represents a 2D circle area_shape. More...
struct  tellipse
 Represents a 2D, axis-aligned ellipse area_shape. More...
struct  basic_line_t
 TODO: This all needs to be tested. More...
struct  interval
 For interval<T> projected_on_axis(glm::tvec2<T> axis) const;. More...
struct  tshape_intersection
 Circle vs Capsule: https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h#L1393. More...
struct  delaunay_triangulation
 TODO: https://github.com/delfrrr/delaunator-cpp/blob/master/include/delaunator.hpp https://en.wikipedia.org/wiki/Delaunay_triangulation. More...
struct  tpolygon
 Represents a 2D polygon polygon_shape. More...
struct  polygon_triangulation
 The results of a triangulation of an external tpolygon<T>. More...
struct  triangulated_polygon
 Contains both a tpolygon<T> as well as its triangulation. More...
struct  tpolyline
 TODO: Polyline. More...
struct  tray
 Represents a 2D ray. More...
struct  tsegment
 Represents a 2D segment (technically a polygon_shape). More...
struct  tindexed_triangle
 Stores three indices to a indexable_polygonlike that together form a triangle. More...
struct  trec2
 Represents a 2D rectangle polygon_shape. More...

Concepts

concept  shape
 Any contiguous non-empty set of 2D points.
concept  area_shape
 A shape for which the concept of an "area" has a finite interpretation.
concept  polygon_shape
 A shape with vertices and edges.
concept  polygon_area_shape
 An area_shape with vertices and edges.
concept  indexable_polygonlike
 Any type that we can index into which will return a tvec2 of some sort. This includes, for example, std::vector<vec2>.

Typedefs

using capsule
using direction_set
using rec2
using irec2
template<std::floating_point T>
using basic_radians_t
template<std::floating_point T>
using basic_degrees_t
template<std::floating_point T>
using basic_heading_t
using degrees
using radians
using heading
template<typename T>
using basic_polar2d_t
using polar2d
template<std::floating_point T>
using tvec_span
using vec_span
using polygon
using ray
using segment
using triangle
using indexed_triangle
using circle
 A circle with float cordinates.
using ellipse

Enumerations

enum class  direction {
  none , right , right_down , down ,
  left_down , left , left_up , up ,
  right_up , east , south_east , south ,
  south_west , west , north_west , north ,
  north_east
}
enum class  winding_order { clockwise , counter_clockwise }

Functions

constexpr direction operator+ (direction dir, int d)
constexpr direction operator- (direction dir, int d)
constexpr direction & operator++ (direction &dir)
constexpr direction & operator-- (direction &dir)
constexpr direction operator++ (direction &dir, int)
constexpr direction operator-- (direction &dir, int)
constexpr direction opposite (direction dir)
constexpr direction next_cardinal (direction dir)
constexpr direction prev_cardinal (direction dir)
constexpr const char * to_name (direction dir)
constexpr const char * to_compass_name (direction dir)
constexpr bool is_valid (direction dir)
constexpr bool is_cardinal (direction dir)
constexpr bool is_diagonal (direction dir)
constexpr direction_set to_cardinal_set (direction dir)
 Turns a diagonal direction into a set of cardinals (e.g. to_cardinal_set(north_west) -> direction_set{north, west}).
constexpr int horizontal (direction dir)
 Returns the horizontal offset (-1, 0, or 1) of dir.
constexpr int vertical (direction dir)
 Returns the vertical offset (-1, 0, or 1) of dir.
constexpr degrees to_angle (direction val)
constexpr glm::ivec2 to_ivec (direction val)
constexpr glm::vec2 to_vec (direction val)
constexpr align to_alignment (direction val)
constexpr direction to_direction (align val)
constexpr direction to_direction (degrees angle)
constexpr direction to_direction (glm::vec2 val)
constexpr direction to_direction (glm::ivec2 vec)
template<typename T>
constexpr T dot (glm::tvec2< T > const &a, glm::tvec2< T > const &b) noexcept
template<typename T>
constexpr glm::tvec2< T > length (glm::tvec2< T > const &a) noexcept
template<typename T>
constexpr std::pair< glm::tvec2< T >, T > dir_and_length (glm::tvec2< T > const &a) noexcept
template<typename T>
constexpr glm::tvec2< T > with_length (glm::tvec2< T > const &a, T length) noexcept
template<typename T>
constexpr glm::tvec2< T > clamp_length (glm::tvec2< T > const &a, T min, T max) noexcept
template<typename T>
constexpr glm::tvec2< T > max_length (glm::tvec2< T > const &a, T max) noexcept
 ghassanpl_named_float_literal (degrees, _deg)
 ghassanpl_named_float_literal (degrees, _rad)
 ghassanpl_named_float_literal (degrees, _head)
template<std::floating_point T>
constexpr basic_degrees_t< T > to_degrees (basic_radians_t< T > r)
template<std::floating_point T>
constexpr basic_radians_t< T > to_radians (basic_degrees_t< T > r)
template<typename TARGET, std::floating_point T>
constexpr TARGET named_cast (basic_radians_t< T > const &radians)
template<typename TARGET, std::floating_point T>
constexpr TARGET named_cast (basic_degrees_t< T > const &degrees)
template<typename T>
basic_radians_t< T > rho (basic_polar2d_t< T > const &polar)
template<typename T>
basic_radians_t< T > phi (basic_polar2d_t< T > const &polar)
template<typename T>
basic_radians_t< T > theta (basic_polar2d_t< T > const &polar)
template<typename T>
basic_polar2d_t< T > polar (glm::tvec2< T > const &euclidean)
template<typename T>
basic_polar2d_t< T > polar_rho_phi (basic_radians_t< T > rho, basic_radians_t< T > phi)
template<typename T>
glm::tvec2< T > euclidean (basic_polar2d_t< T > const &polar)
template<typename T>
basic_line_t< T > line_crossing_points (glm::tvec2< T > const &p1, glm::tvec2< T > const &p2)
 TODO: Move these to the body as static methods?
template<typename T>
basic_line_t< T > line_from_dir (glm::tvec2< T > const &dir)
template<typename T>
interval< T > projected_on_axis (glm::tvec2< T > axis, glm::tvec2< T > const &point)
template<typename T, typename U>
bool intersects (T const &, U const &) noexcept=delete
 TODO: Steal from: https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h.
template<typename T>
bool intersects (trec2< T > const &a, trec2< T > const &b) noexcept
template<typename T>
bool intersects< tcircle< T >, tcircle< T > > (tcircle< T > const &a, tcircle< T > const &b) noexcept
template<typename T, typename U>
void intersection (T const &, U const &) noexcept=delete
template<typename T, typename FUNC>
auto linear_interpolation (std::span< vertex_weight< T > > weights, FUNC &&value_func)
template<std::ranges::range RANGE, typename T = std::ranges::range_value_t<RANGE>>
constexpr bool are_colinear (RANGE const &range, T tolerance=precision_limits< T >::point_on_line_max_distance)
 Checks if the points in range are colinear.
template<indexable_polygonlike POLY, typename IDX_TYPE = size_t>
auto calculate_indexed_triangle_area (POLY const &poly, tindexed_triangle< IDX_TYPE > const &triangle)
template<typename TR>
auto calculate_total_area (TR const &trpoly)
template<typename T>
polygon_triangulation< T > triangulate (tpolygon< T > const &poly)
template<typename T>
trec2< T > operator+ (glm::tvec2< T > op, trec2< T > rec) noexcept
template<typename T, shape< T > S>
auto distance (S const &sh, glm::tvec2< T > pt)
 Returns the distance between a shape and a point.
template<typename T, shape< T > S>
auto distance (glm::tvec2< T > pt, S const &sh)
template<typename T, shape< T > S>
auto distance_squared (S const &sh, glm::tvec2< T > pt)
template<typename T, shape< T > S>
auto distance_squared (glm::tvec2< T > pt, S const &sh)
template<typename T>
std::optional< T > axis_overlaps (shape< T > auto const &a, shape< T > auto const &b, glm::vec2 const &axis)

Variables

static constexpr auto direction_count
constexpr direction_set all_cardinal_directions
constexpr direction_set all_diagonal_directions
constexpr direction_set all_directions
static constexpr size_t invalid_index
static constexpr struct ghassanpl::geometry::bounding_box_for_t bounding_box_for

Detailed Description


Class Documentation

◆ ghassanpl::geometry::tshape_intersection

struct ghassanpl::geometry::tshape_intersection
template<typename T>
struct ghassanpl::geometry::tshape_intersection< T >

Circle vs Capsule: https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h#L1393.

Definition at line 51 of file intersection.h.

Class Members
tvec2< T > normal x,y - point, z - depth
tvec3< T > points_and_depths[2]

Typedef Documentation

◆ basic_polar2d_t

template<typename T>
using ghassanpl::geometry::basic_polar2d_t

Definition at line 261 of file geometry_common.h.

◆ capsule

using ghassanpl::geometry::capsule

Definition at line 46 of file capsule.h.

◆ circle

A circle with float cordinates.

Definition at line 63 of file circle.h.

◆ ellipse

using ghassanpl::geometry::ellipse

Definition at line 57 of file ellipse.h.

◆ irec2

using ghassanpl::geometry::irec2

Definition at line 79 of file geometry_common.h.

◆ polar2d

using ghassanpl::geometry::polar2d

Definition at line 263 of file geometry_common.h.

◆ ray

using ghassanpl::geometry::ray

Definition at line 53 of file ray.h.

◆ rec2

using ghassanpl::geometry::rec2

Definition at line 78 of file geometry_common.h.

◆ segment

using ghassanpl::geometry::segment

Definition at line 143 of file segment.h.

Enumeration Type Documentation

◆ winding_order

enum class ghassanpl::geometry::winding_order
strong

Definition at line 81 of file geometry_common.h.

Function Documentation

◆ axis_overlaps()

template<typename T>
std::optional< T > ghassanpl::geometry::axis_overlaps ( shape< T > auto const & a,
shape< T > auto const & b,
glm::vec2 const & axis )

Definition at line 48 of file shape_concepts.h.

◆ clamp_length()

template<typename T>
glm::tvec2< T > ghassanpl::geometry::clamp_length ( glm::tvec2< T > const & a,
T min,
T max )
constexprnoexcept

Definition at line 119 of file geometry_common.h.

◆ dir_and_length()

template<typename T>
std::pair< glm::tvec2< T >, T > ghassanpl::geometry::dir_and_length ( glm::tvec2< T > const & a)
constexprnoexcept

Definition at line 103 of file geometry_common.h.

◆ distance() [1/2]

template<typename T, shape< T > S>
auto ghassanpl::geometry::distance ( glm::tvec2< T > pt,
S const & sh )

Definition at line 42 of file shape_concepts.h.

◆ distance() [2/2]

template<typename T, shape< T > S>
auto ghassanpl::geometry::distance ( S const & sh,
glm::tvec2< T > pt )

Returns the distance between a shape and a point.

Definition at line 41 of file shape_concepts.h.

◆ distance_squared() [1/2]

template<typename T, shape< T > S>
auto ghassanpl::geometry::distance_squared ( glm::tvec2< T > pt,
S const & sh )

Definition at line 45 of file shape_concepts.h.

◆ distance_squared() [2/2]

template<typename T, shape< T > S>
auto ghassanpl::geometry::distance_squared ( S const & sh,
glm::tvec2< T > pt )

Definition at line 44 of file shape_concepts.h.

◆ dot()

template<typename T>
T ghassanpl::geometry::dot ( glm::tvec2< T > const & a,
glm::tvec2< T > const & b )
constexprnoexcept

Definition at line 88 of file geometry_common.h.

◆ euclidean()

template<typename T>
glm::tvec2< T > ghassanpl::geometry::euclidean ( basic_polar2d_t< T > const & polar)

Definition at line 284 of file geometry_common.h.

◆ intersects()

template<typename T>
bool ghassanpl::geometry::intersects ( trec2< T > const & a,
trec2< T > const & b )
noexcept

Definition at line 26 of file intersection.h.

◆ intersects< tcircle< T >, tcircle< T > >()

template<typename T>
bool ghassanpl::geometry::intersects< tcircle< T >, tcircle< T > > ( tcircle< T > const & a,
tcircle< T > const & b )
noexcept

Definition at line 32 of file intersection.h.

◆ length()

template<typename T>
glm::tvec2< T > ghassanpl::geometry::length ( glm::tvec2< T > const & a)
constexprnoexcept

Definition at line 97 of file geometry_common.h.

◆ linear_interpolation()

template<typename T, typename FUNC>
auto ghassanpl::geometry::linear_interpolation ( std::span< vertex_weight< T > > weights,
FUNC && value_func )

Definition at line 54 of file point_cloud.h.

◆ max_length()

template<typename T>
glm::tvec2< T > ghassanpl::geometry::max_length ( glm::tvec2< T > const & a,
T max )
constexprnoexcept

Definition at line 133 of file geometry_common.h.

◆ operator+()

template<typename T>
trec2< T > ghassanpl::geometry::operator+ ( glm::tvec2< T > op,
trec2< T > rec )
noexcept

Definition at line 382 of file rec2.h.

◆ phi()

template<typename T>
basic_radians_t< T > ghassanpl::geometry::phi ( basic_polar2d_t< T > const & polar)
inline

Definition at line 266 of file geometry_common.h.

◆ polar()

template<typename T>
basic_polar2d_t< T > ghassanpl::geometry::polar ( glm::tvec2< T > const & euclidean)

Definition at line 270 of file geometry_common.h.

◆ polar_rho_phi()

template<typename T>
basic_polar2d_t< T > ghassanpl::geometry::polar_rho_phi ( basic_radians_t< T > rho,
basic_radians_t< T > phi )

Definition at line 278 of file geometry_common.h.

◆ rho()

template<typename T>
basic_radians_t< T > ghassanpl::geometry::rho ( basic_polar2d_t< T > const & polar)
inline

Definition at line 265 of file geometry_common.h.

◆ theta()

template<typename T>
basic_radians_t< T > ghassanpl::geometry::theta ( basic_polar2d_t< T > const & polar)
inline

Definition at line 267 of file geometry_common.h.

◆ with_length()

template<typename T>
glm::tvec2< T > ghassanpl::geometry::with_length ( glm::tvec2< T > const & a,
T length )
constexprnoexcept

Definition at line 112 of file geometry_common.h.

Variable Documentation

◆ invalid_index

size_t ghassanpl::geometry::invalid_index
inlinestaticconstexpr

Definition at line 14 of file point_cloud.h.