-
Notifications
You must be signed in to change notification settings - Fork 2
/
CoordPair.h
131 lines (100 loc) · 3.11 KB
/
CoordPair.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Datei CoordPair.h
Diese Datei enthält die Definition der Hilfsklasse CoordPair:
- struct CoordPair
sowie einiger Operatoren für diese Klasse
*/
#ifndef COORDPAIR_H
#define COORDPAIR_H
#pragma warning(disable: 4786)
#pragma warning(disable: 4800)
#include <cmath>
#include "constant.h"
struct CoordPair
{
double x; // x-Koordinate
double y; // y-Koordinate
double z; // z-Koordinate
double m; // m-Koordinate
CoordPair (void) : x (0.0), y (0.0), z (0.0), m (0.0) {}
CoordPair (double X, double Y) : x (X), y (Y), z (0.0), m (0.0) {}
CoordPair (double X, double Y, double Z, double M) : x (X), y (Y), z (Z), m (M) {}
CoordPair (const CoordPair& oldCP) : x (oldCP.x), y (oldCP.y), z (oldCP.z), m (oldCP.m) {}
virtual ~CoordPair () {}
CoordPair operator= (const CoordPair& rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
m = rhs.m;
return *this;
}
CoordPair operator+= (const CoordPair& rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
return *this;
}
CoordPair operator-= (const CoordPair& rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
return *this;
}
CoordPair operator*= (const double& fac)
{
x *= fac;
y *= fac;
z *= fac;
return *this;
}
CoordPair normalized (void) const
{
double betr = sqrt (x * x + y * y + z * z);
return CoordPair (x / betr, y / betr, z / betr, m);
}
CoordPair scaledBy (const CoordPair& Scales)
{
return CoordPair (Scales.x * x, Scales.y * y, Scales.z * z, m );
}
double length (void) const
{
return sqrt (x * x + y * y + z * z);
}
};
inline
CoordPair operator+ (const CoordPair& CP1, const CoordPair& CP2)
{ return CoordPair (CP1.x + CP2.x, CP1.y + CP2.y, CP1.z + CP2.z, CP1.m + CP2.m); }
inline
CoordPair operator- (const CoordPair& CP1, const CoordPair& CP2)
{ return CoordPair (CP1.x - CP2.x, CP1.y - CP2.y, CP1.z - CP2.z, CP1.m - CP2.m); }
inline
CoordPair operator* (const double& fac, const CoordPair& CP)
{ return CoordPair (fac * CP.x, fac * CP.y, fac * CP.z, fac * CP.m); }
inline
CoordPair operator* (const CoordPair& CP, const double& fac)
{ return CoordPair (fac * CP.x, fac * CP.y, fac * CP.z, fac * CP.m); }
inline
double operator* (const CoordPair& CP1, const CoordPair& CP2)
{ return (CP1.x * CP2.x + CP1.y * CP2.y, CP1.z * CP2.z); }
inline
bool operator== (const CoordPair& CP1, const CoordPair& CP2)
{ return ((fabs (CP2.x - CP1.x) < MINIMAL_POINT_DISTANCE) &&
(fabs (CP2.y - CP1.y) < MINIMAL_POINT_DISTANCE) &&
(fabs (CP2.z - CP1.z) < MINIMAL_POINT_DISTANCE) &&
(fabs (CP2.m - CP1.m) < MINIMAL_POINT_DISTANCE) );
}
inline
bool operator!= (const CoordPair& CP1, const CoordPair& CP2)
{ return (!(CP1 == CP2)); }
struct PLVertex : CoordPair
{
double bulge;
PLVertex (void) : CoordPair (), bulge (0.0) {}
PLVertex (double X, double Y, double B = 0.0) : CoordPair (X, Y), bulge (B) {}
PLVertex (const PLVertex& oldPLV) : CoordPair (oldPLV), bulge (oldPLV.bulge) {}
explicit PLVertex (const CoordPair& oldCP, double B = 0.0)
: CoordPair (oldCP), bulge (B) {}
};
#endif