Horizon
3rd_party
delaunay-triangulation
vector2.h
1
#ifndef H_VECTOR2
2
#define H_VECTOR2
3
4
#include <iostream>
5
#include <cmath>
6
namespace
delaunay
{
7
template
<
typename
T>
8
class
Vector2
9
{
10
public
:
11
//
12
// Constructors
13
//
14
15
Vector2
()
16
{
17
x = 0;
18
y = 0;
19
}
20
21
Vector2
(T _x, T _y,
int
aid=0)
22
{
23
x = _x;
24
y = _y;
25
id
= aid;
26
}
27
28
Vector2
(
const
Vector2
&v)
29
{
30
x = v.x;
31
y = v.y;
32
id
= v.id;
33
}
34
35
//
36
// Operations
37
//
38
T dist2(
const
Vector2
&v)
const
39
{
40
T dx = x - v.x;
41
T dy = y - v.y;
42
return
dx * dx + dy * dy;
43
}
44
45
float
dist(
const
Vector2
&v)
46
{
47
return
sqrtf(dist2(v));
48
}
49
50
T x;
51
T y;
52
int
id
=0;
53
int
tag=0;
54
};
55
56
template
<
typename
T>
57
std::ostream &operator << (std::ostream &str, Vector2<T>
const
&point)
58
{
59
return
str <<
"Point x: "
<< point.x <<
" y: "
<< point.y <<
" tag: "
<< point.tag;
60
}
61
62
template
<
typename
T>
63
bool
operator == (
Vector2<T>
v1,
Vector2<T>
v2)
64
{
65
return
(v1.x == v2.x) && (v1.y == v2.y);
66
}
67
}
68
#endif
delaunay::Vector2
Definition:
vector2.h:8
delaunay
Definition:
delaunay.h:10
Generated by
1.8.13