From 672819693ddf1d203c304697b63f44059cff09b6 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 26 Jan 2022 02:23:20 -0600 Subject: refactor: move quadtree and util functions into separate headers and clean up names --- experimental/tectonics/tectonics.h | 52 +------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) (limited to 'experimental/tectonics/tectonics.h') diff --git a/experimental/tectonics/tectonics.h b/experimental/tectonics/tectonics.h index b2793e9..de5b18a 100644 --- a/experimental/tectonics/tectonics.h +++ b/experimental/tectonics/tectonics.h @@ -5,27 +5,7 @@ #include #include -struct point_t { - double x, y; - void *data; -}; - - -struct quad_region_t { - struct point_t center; - double half_dim; -}; - - -struct quadtree_node_t { - struct quad_region_t region; - - int id; - - /* children */ - struct quadtree_node_t *nw, *ne, *sw, *se; -}; - +#include "geometry.h" struct world_t { struct point_t *points; @@ -33,36 +13,6 @@ struct world_t { int n_points; }; -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * quadtree - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - -bool contains_point(struct quad_region_t region, struct point_t pt); -struct quadtree_node_t new_node(struct point_t center, double half_dim); -void subdivide(struct quadtree_node_t *node, struct point_t *points); -bool insert(struct quadtree_node_t *node, - struct point_t *points, int id); -int get_closest(struct quadtree_node_t *root, - struct point_t *points, - struct point_t pt); -void draw_quadtree(cairo_t *cr, struct quadtree_node_t *root); -void free_tree(struct quadtree_node_t *root); - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * util - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - -void get_cairo_size(cairo_t *cr, int *width, int *height); -double rand01(); -double distance(struct point_t p1, struct point_t p2); - - /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * worlds -- cgit v1.2.1