header_utils
Loading...
Searching...
No Matches
points.h
1
4
5#pragma once
6
7#include "geometry_common.h"
8
10{
14
16 template <std::ranges::range RANGE, typename T = std::ranges::range_value_t<RANGE>>
17 constexpr bool are_colinear(RANGE const& range, T tolerance = precision_limits<T>::point_on_line_max_distance)
18 {
19 if (std::ranges::size(range) < 3)
20 return true;
21
22 auto it = std::ranges::begin(range);
23
24 const auto line = line_crossing_points(*it++, *it++);
25 const auto end = std::ranges::end(range);
26 while (it != end)
27 {
28 if (line.distance(*it++) > tolerance)
29 return false;
30 }
31
32 return true;
33 }
34
35 template <std::floating_point T>
36 using tvec_span = std::span<glm::tvec2<T>>;
37
38 using vec_span = tvec_span<float>;
39
41}
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?
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.
Definition points.h:17