7#include "geometry_common.h"
13 template <std::
floating_po
int T>
16 using tvec = glm::tvec2<T>;
23 template <
typename FUNC>
40 return glm::distance(a, b) + glm::distance(b, c) + glm::distance(c, a);
43 glm::tvec2<T> edge_point_alpha(T
t)
const;
44 glm::tvec2<T> edge_point(T
t)
const;
45 glm::tvec2<T> projected(glm::tvec2<T>
pt)
const;
47 static auto sign(tvec
const& p1, tvec
const& p2, tvec
const&
p3)
noexcept
49 return (p1.x -
p3.x) * (p2.y -
p3.y) - (p2.x -
p3.x) * (p1.y -
p3.y);
54 const auto d = sign(a, b, c);
55 return d > 0 ? winding_order::clockwise : winding_order::counter_clockwise;
60 const auto d1 = sign(
pt, a, b);
61 const auto d2 = sign(
pt, b, c);
62 const auto d3 = sign(
pt, c, a);
70 const auto A = std::sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
71 const auto B = std::sqrt((b.x - c.x) * (b.x - c.x) + (b.y - c.y) * (b.y - c.y));
72 const auto C = std::sqrt((b.x - c.x) * (a.x - c.x) + (a.y - c.y) * (a.y - c.y));
73 const auto s = (
A +
B +
C) * T(0.5);
74 return std::sqrt(
s * (
s -
A) * (
s -
B) * (
s -
C));
81 template <std::
integral IDX =
size_t>
82 struct tindexed_triangle
84 std::array<IDX, 3> indices{};
86 template <std::ranges::random_access_range T>
87 auto a(T&&
range)
const -> std::ranges::range_value_t<T>
89 return range[indices[0]];
91 template <std::ranges::random_access_range T>
92 auto b(T&&
range)
const -> std::ranges::range_value_t<T>
94 return range[indices[1]];
96 template <std::ranges::random_access_range T>
97 auto c(T&&
range)
const -> std::ranges::range_value_t<T>
99 return range[indices[2]];
102 template <std::ranges::random_access_range T>
constexpr auto bit_count
Equal to the number of bits in the type.
constexpr decltype(auto) at(random_access_range auto &range, std::integral auto index)
Returns a reference to the value at index of range
constexpr __contains_fn contains
contains(range, el)