31#ifndef ALEPH_TEST_GEOM_ALGORITHMS_TEST_COMMON_H
32#define ALEPH_TEST_GEOM_ALGORITHMS_TEST_COMMON_H
34#include <gtest/gtest.h>
48 [[maybe_unused]]
bool polygon_contains_vertex(
const Polygon & poly,
const Point & p)
54 if (it.get_current_vertex() == p)
69 [[maybe_unused]]
bool matches_unordered_pair(
const Point & a,
const Point & b,
72 return (a == u
and b == v) or (a == v
and b == u);
94 [[maybe_unused]]
void sort3(
size_t & a,
size_t & b,
size_t & c)
130 for (
size_t i = 0; i <
r.triangles.size(); ++i)
132 size_t a =
r.triangles(i).i;
133 size_t b =
r.triangles(i).j;
134 size_t c =
r.triangles(i).k;
136 out.append(TriKey{a, b, c});
172 const Geom_Number d = ax * (by - cy) + bx * (cy - ay) + cx * (ay - by);
176 <<
"circumcenter_of: collinear triangle (zero area)";
179 (a2 * (by - cy) + b2 * (cy - ay) + c2 * (ay - by)) / den,
180 (a2 * (cx - bx) + b2 * (ax - cx) + c2 * (bx - ax)) / den
204 if (a < 0) { a = -a; }
214 [[maybe_unused]]
bool is_ccw(
const Polygon & poly)
228 if (a < 0) { a = -a; }
241 for (
auto it = points.
get_it(); it.has_curr(); it.next_ne())
243 loc == PointInPolygonWinding::Location::Outside)
254 [[maybe_unused]]
bool polygon_is_convex(
const Polygon & poly)
259 verts.
append(it.get_current_vertex());
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
size_t size_t int32_t * out
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
void reserve(size_t cap)
Reserves cap cells into the array.
bool has_curr() const noexcept
Return true if the iterator has current item.
Doubly-linked list (defined in tpl_dynList.H).
static bool is_convex(const Array< Point > &verts)
Check if a vertex array forms a convex polygon.
static Geom_Number signed_double_area(const Array< Point > &verts)
Compute twice the signed area (shoelace formula without division).
static Location locate(const Polygon &poly, const Point &p)
Classify point location with respect to a polygon.
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
A general (irregular) 2D polygon defined by a sequence of vertices.
const size_t & size() const
Get the number of vertices.
A non-degenerate triangle defined by three points.
Geom_Number area() const
Calculates the unsigned area of the triangle.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Computational geometry algorithms.
double triangle_area(const Triangle &t)
Calculate area of a triangle using cross product.
void sort3(T *a, T *b, T *c, const Compare &cmp)
Sort *a, *b and *c.
and
Check uniqueness with explicit hash + equality functors.
void quicksort_op(C< T > &a, const Compare &cmp=Compare(), const size_t threshold=Quicksort_Threshold)
Optimized quicksort for containers using operator().
static Geom_Number polygon_area(const Polygon &poly)
The result of a Delaunay triangulation.
Iterator over the vertices of a polygon.