diff options
author | sanine <sanine.not@pm.me> | 2022-01-26 02:23:20 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-01-26 02:23:20 -0600 |
commit | 672819693ddf1d203c304697b63f44059cff09b6 (patch) | |
tree | 258319d46efa5297162bc1179b5c9c34bd3c23c7 /experimental/tectonics/tectonics.h | |
parent | c5fae17327c585ec09ad01066e3f24a4e7be1fed (diff) |
refactor: move quadtree and util functions into separate headers and clean up names
Diffstat (limited to 'experimental/tectonics/tectonics.h')
-rw-r--r-- | experimental/tectonics/tectonics.h | 52 |
1 files changed, 1 insertions, 51 deletions
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 <stdbool.h> #include <cairo.h> -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; @@ -35,36 +15,6 @@ struct world_t { /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * 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 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |