5#include <SDL2/SDL_image.h>
6#include <box2d/box2d.h>
76std::vector<std::vector<b2Vec2>>
read_poly_from_csv(
const std::string& filename,
float total_surface);
117std::vector<b2Vec2>
offset_polygon(
const std::vector<b2Vec2>& polygon,
float offset);
139 const std::vector<std::vector<b2Vec2>> &polygons,
140 const std::vector<float> &reserve_radii,
141 float max_neighbor_distance = std::numeric_limits<float>::infinity(),
142 std::uint32_t attempts_per_point = 100U,
143 std::uint32_t max_restarts = 100U);
171 std::size_t n_samples = 20'000,
172 std::size_t kmeans_iterations = 20,
173 std::uint32_t max_restarts = 3);
208 const std::vector<std::vector<b2Vec2>> &polygons,
209 const std::vector<float> &reserve_radii,
210 std::size_t n_samples = 25'000,
211 std::size_t kmeans_iterations = 25,
212 float convergence_eps = 1e-3f,
213 std::uint32_t max_restarts = 3);
228 const std::vector<std::vector<b2Vec2>> &polygons,
229 const std::vector<float> &reserve_radii,
230 std::uint32_t attempts_per_point = 1'000U,
231 std::uint32_t max_restarts = 25U);
262 const std::vector<std::vector<b2Vec2>> &polygons,
263 std::size_t n_points,
265 bool cluster_center =
false);
356std::tuple<std::vector<b2Vec2>, std::vector<float>>
358 const size_t nb_objects,
359 const std::string& formation_filename,
360 const std::pair<float, float>& imported_formation_min_coords,
361 const std::pair<float, float>& imported_formation_max_coords);
float visualization_y
Global visualization offset for the y-coordinate.
Definition geometry.cpp:27
float mm_to_pixels
Global scaling factor from millimeters to pixels.
Definition geometry.cpp:25
float visualization_x
Global visualization offset for the x-coordinate.
Definition geometry.cpp:26
std::tuple< std::vector< b2Vec2 >, std::vector< float > > import_points_from_file(const arena_polygons_t &scaled_arena_polygons, const size_t nb_objects, const std::string &formation_filename, const std::pair< float, float > &imported_formation_min_coords, const std::pair< float, float > &imported_formation_max_coords)
Import and rescale robot formation points.
Definition geometry.cpp:1622
float compute_polygon_area(const std::vector< b2Vec2 > &poly)
Computes the area of a polygon using the shoelace formula.
Definition geometry.cpp:1140
std::vector< b2Vec2 > generate_random_points_layered(const std::vector< std::vector< b2Vec2 > > &polygons, const std::vector< float > &reserve_radii, std::uint32_t attempts_per_point=1 '000U, std::uint32_t max_restarts=25U)
Definition geometry.cpp:441
b2Vec2 visualization_position(float x, float y)
Calculates the visualization position for given x and y coordinates.
Definition geometry.cpp:39
b2Vec2 polygon_centroid(const std::vector< b2Vec2 > &polygon)
Computes the centroid of a polygon.
Definition geometry.cpp:1153
std::vector< std::vector< b2Vec2 > > arena_polygons_t
Definition geometry.h:13
float point_to_line_segment_distance(const b2Vec2 &p, const b2Vec2 &a, const b2Vec2 &b)
Calculates the distance from a point to a line segment.
Definition geometry.cpp:1172
std::vector< b2Vec2 > generate_points_voronoi_lloyd(const std::vector< std::vector< b2Vec2 > > &polygons, std::size_t k, std::size_t n_samples=20 '000, std::size_t kmeans_iterations=20, std::uint32_t max_restarts=3)
Definition geometry.cpp:611
std::vector< std::vector< b2Vec2 > > read_poly_from_csv(const std::string &filename, float total_surface)
Reads polygons from a CSV file and scales them to match a specified surface area.
Definition geometry.cpp:50
void adjust_mm_to_pixels(float delta)
Adjusts the global mm_to_pixels scaling factor.
Definition geometry.cpp:30
std::pair< float, float > compute_polygon_dimensions(const std::vector< b2Vec2 > &polygon)
Computes the width and height of a polygon.
Definition geometry.cpp:1121
std::vector< b2Vec2 > generate_regular_disk_points_in_polygon(const std::vector< std::vector< b2Vec2 > > &polygons, const std::vector< float > &reserve_radii)
Place points on (approximate) concentric rings inside polygons[0] so that: • point i stays ≥ reserve_...
Definition geometry.cpp:1198
std::vector< b2Vec2 > generate_chessboard_points(const std::vector< std::vector< b2Vec2 > > &polygons, std::size_t n_points, float pitch, bool cluster_center=false)
Generate a square-grid ("checkerboard") layout with **exactly n_points** nodes inside a (possibly hol...
Definition geometry.cpp:903
b2Vec2 generate_random_point_within_polygon(const std::vector< b2Vec2 > &polygon)
Generates a random point within the specified polygon.
Definition geometry.cpp:140
std::vector< b2Vec2 > generate_random_points_within_polygon_safe(const std::vector< std::vector< b2Vec2 > > &polygons, const std::vector< float > &reserve_radii, float max_neighbor_distance=std::numeric_limits< float >::infinity(), std::uint32_t attempts_per_point=100U, std::uint32_t max_restarts=100U)
Definition geometry.cpp:278
std::vector< b2Vec2 > offset_polygon(const std::vector< b2Vec2 > &polygon, float offset)
Computes an offset polygon.
Definition geometry.cpp:196
bool is_point_within_polygon(const std::vector< b2Vec2 > &polygon, float x, float y)
Determines whether a point is within a polygon.
Definition geometry.cpp:173
std::vector< b2Vec2 > generate_random_points_power_lloyd(const std::vector< std::vector< b2Vec2 > > &polygons, const std::vector< float > &reserve_radii, std::size_t n_samples=25 '000, std::size_t kmeans_iterations=25, float convergence_eps=1e-3f, std::uint32_t max_restarts=3)
Uniformly sample approximately equi-spaced points in a (possibly holed) polygonal domain,...
Definition geometry.cpp:739
float const VISUALIZATION_SCALE
Definition geometry.h:15