-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquadtree.h
More file actions
37 lines (30 loc) · 1.13 KB
/
quadtree.h
File metadata and controls
37 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef QUADTREE_H
#define QUADTREE_H
#include <stdbool.h> // <-- This line fixes the 'bool' syntax error
#include "driver.h"
// A structure to represent a rectangle, renamed to avoid conflicts
// This definition includes the missing members.
typedef struct QT_Rectangle {
double x; // Center x-coordinate
double y; // Center y-coordinate
double half_width; // Half of the width
double half_height; // Half of the height
} QT_Rectangle;
// The main Quadtree node structure
typedef struct QuadtreeNode {
QT_Rectangle boundary;
Driver** drivers; // Points to an array of drivers
int driverCount;
int capacity;
// Children
struct QuadtreeNode* northwest;
struct QuadtreeNode* northeast;
struct QuadtreeNode* southwest;
struct QuadtreeNode* southeast;
} QuadtreeNode;
// Function Prototypes
QuadtreeNode* createQuadtree(QT_Rectangle boundary, int capacity);
void insert(QuadtreeNode* qt, Driver* driver);
void queryRange(QuadtreeNode* qt, QT_Rectangle range, Driver** found, int* count);
void freeQuadtree(QuadtreeNode* qt);
#endif // QUADTREE_H