-
Notifications
You must be signed in to change notification settings - Fork 0
/
VEdge.h
73 lines (57 loc) · 1.38 KB
/
VEdge.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
#ifndef VEDGE_H
#define VEDGE_H
#include "VPoint.h"
#include <iostream>
/*
A class that stores an edge in Voronoi diagram
start : pointer to start point
end : pointer to end point
left : pointer to Voronoi place on the left side of edge
right : pointer to Voronoi place on the right side of edge
neighbour : some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm
direction : directional vector, from "start", points to "end", normal of |left, right|
f, g : directional coeffitients satisfying equation y = f*x + g (edge lies on this line)
*/
class VEdge
{
public:
VPoint * start;
VPoint * end;
VPoint * direction;
VPoint * left;
VPoint * right;
double f;
double g;
VEdge * neighbour;
/*
Constructor of the class
s : pointer to start
a : pointer to left place
b : pointer to right place
*/
VEdge()
{
f=0;
g=0;
}
VEdge(VPoint * s, VPoint * a, VPoint * b)
{
start = s;
left = a;
right = b;
neighbour = 0;
end = 0;
f = (b->x - a->x) / (a->y - b->y) ;
g = s->y - f * s->x ;
direction = new VPoint(b->y - a->y, -(b->x - a->x));
}
/*
Destructor of the class
direction belongs only to the current edge, other pointers can be shared by other edges
*/
~VEdge()
{
delete direction ;
}
};
#endif