blob: aba9818036be68140ed15b199b345557f4c3f0d2 (
plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
|
/* operator functions for NR::Point. */
#ifndef SEEN_NR_POINT_OPS_H
#define SEEN_NR_POINT_OPS_H
#include <libnr/nr-point.h>
namespace NR {
inline Point operator+(Point const &a, Point const &b)
{
Point ret;
for (int i = 0; i < 2; i++) {
ret[i] = a[i] + b[i];
}
return ret;
}
inline Point operator-(Point const &a, Point const &b)
{
Point ret;
for (int i = 0; i < 2; i++) {
ret[i] = a[i] - b[i];
}
return ret;
}
/** This is a rotation (sort of). */
inline Point operator^(Point const &a, Point const &b)
{
Point const ret(a[0] * b[0] - a[1] * b[1],
a[1] * b[0] + a[0] * b[1]);
return ret;
}
inline Point operator-(Point const &a)
{
Point ret;
for(unsigned i = 0; i < 2; i++) {
ret[i] = -a[i];
}
return ret;
}
inline Point operator*(double const s, Point const &b)
{
Point ret;
for(int i = 0; i < 2; i++) {
ret[i] = s * b[i];
}
return ret;
}
inline Point operator/(Point const &b, double const d)
{
Point ret;
for(int i = 0; i < 2; i++) {
ret[i] = b[i] / d;
}
return ret;
}
inline bool operator==(Point const &a, Point const &b)
{
return ( ( a[X] == b[X] ) && ( a[Y] == b[Y] ) );
}
inline bool operator!=(Point const &a, Point const &b)
{
return ( ( a[X] != b[X] ) || ( a[Y] != b[Y] ) );
}
} /* namespace NR */
#endif /* !SEEN_NR_POINT_OPS_H */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|