-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointquadtree.h
76 lines (52 loc) · 1.65 KB
/
pointquadtree.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef POINTQUADTREE_H
#define POINTQUADTREE_H
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <queue>
#define MAX 500
using namespace std;
struct Node
{
int x;
int y;
int colour;
struct Node* NW;
struct Node* NE;
struct Node* SE;
struct Node* SW;
int LN;
int LS;
int LE;
int LW;
};
class PointQuadtree
{
public:
int xc, yc, xc2, yc2, rc;
struct Node* root;
struct Node* target;
PointQuadtree();
struct Node* makeNode(int x, int y);
struct Node* makeNode(int x, int y, int colr);
//check to see if two Nodes are equal
bool equalCoordinates(struct Node* temp, struct Node* target);
//return the successive quadrant where toBeInserted will be further inserted
struct Node* getQuadrant(struct Node* temp, struct Node* target);
//insert into the final quadrant found
void insertPointInFinalQuadrant(struct Node* temp, struct Node* target);
//insert: @return true for successful search, false for unsuccessful search
bool insert(int x, int y);
//randomize: gfgfgf
void randomize(int N);
int dist(int x1, int y1, int x2, int y2);
bool inCircle(int x, int y, int r, struct Node* target);
//searching: @return true for successful search, false for unsuccessful search
bool search(int x, int y);
//function for level order traversal using BFS + checking for existence inside a circle or not
void checkCircle(int x, int y, int r);
protected:
private:
};
#endif // POINTQUADTREE_H