3 #ifdef DELAUNATOR_HEADER_ONLY
13 namespace delaunator {
15 constexpr std::size_t INVALID_INDEX =
16 (std::numeric_limits<std::size_t>::max)();
21 Point(
double x,
double y) : m_x(x), m_y(y)
23 Point() : m_x(0), m_y(0)
32 double magnitude2()
const
33 {
return m_x * m_x + m_y * m_y; }
35 static double determinant(
const Point& p1,
const Point& p2)
37 return p1.m_x * p2.m_y - p1.m_y * p2.m_x;
42 return Point(p2.m_x - p1.m_x, p2.m_y - p1.m_y);
45 static double dist2(
const Point& p1,
const Point& p2)
47 Point vec = vector(p1, p2);
48 return vec.m_x * vec.m_x + vec.m_y * vec.m_y;
51 static bool equal(
const Point& p1,
const Point& p2,
double span)
53 double dist = dist2(p1, p2) / span;
65 inline std::ostream& operator<<(std::ostream& out,
const Point& p)
67 out << p.x() <<
"/" << p.y();
75 using const_iterator =
Point const *;
77 Points(
const std::vector<double>& coords) : m_coords(coords)
80 const Point& operator[](
size_t offset)
82 return reinterpret_cast<const Point&
>(
83 *(m_coords.data() + (offset * 2)));
86 Points::const_iterator begin()
const
87 {
return reinterpret_cast<const Point *
>(m_coords.data()); }
88 Points::const_iterator end()
const
89 {
return reinterpret_cast<const Point *
>(
90 m_coords.data() + m_coords.size()); }
92 {
return m_coords.size() / 2; }
95 const std::vector<double>& m_coords;
101 std::vector<double>
const& coords;
106 std::vector<std::size_t> triangles;
114 std::vector<std::size_t> halfedges;
116 std::vector<std::size_t> hull_prev;
117 std::vector<std::size_t> hull_next;
120 std::vector<std::size_t> hull_tri;
121 std::size_t hull_start;
123 INLINE
Delaunator(std::vector<double>
const& in_coords);
124 INLINE
double get_hull_area();
125 INLINE
double get_triangle_area();
128 std::vector<std::size_t> m_hash;
130 std::size_t m_hash_size;
131 std::vector<std::size_t> m_edge_stack;
133 INLINE std::size_t legalize(std::size_t a);
134 INLINE std::size_t hash_key(
double x,
double y)
const;
135 INLINE std::size_t add_triangle(
142 INLINE
void link(std::size_t a, std::size_t b);
Definition: delaunator.hpp:98
Definition: delaunator.hpp:19
Definition: delaunator.hpp:73