7#include "geometry_common.h"
12 template <std::
floating_po
int T>
15 using tvec = glm::tvec2<T>;
23 tray from_dir(tvec
const& start, tvec
const& dir)
noexcept {
return { start, glm::normalize(dir) }; }
24 tray from_points(tvec
const& start, tvec
const&
second)
noexcept {
return from_dir(start,
second - start); }
26 tsegment& set_position(tvec
const&
pos)
noexcept { start =
pos;
return *
this; }
27 tsegment& operator+=(tvec
const&
offs)
noexcept { start +=
offs;
return *
this; }
28 tsegment& operator-=(tvec
const&
offs)
noexcept { start -=
offs;
return *
this; }
29 tsegment& translate(tvec
const&
offs)
noexcept {
return this->operator+=(
offs); }
31 tvec edge_point_alpha(T
t)
const {
return start + dir *
t; }
32 tvec projected(tvec
const&
pt)
const
34 const auto a = projected_alpha(
pt);
35 if (a < T(0))
return start;
36 return start + dir * a;
38 T projected_alpha(tvec
const&
pt)
const
40 const auto d =
pt - start;
41 return glm::dot(
d, dir);
constexpr auto bit_count
Equal to the number of bits in the type.