Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
4DPoint.h
1
// 4DPoint.h: interface for the C4DPoint class.
2
//
3
//////////////////////////////////////////////////////////////////////
4
5
#if !defined(AFX_4DPOINT_H__CA6BC29E_FAC2_11D1_A0DE_000000000000__INCLUDED_)
6
#define AFX_4DPOINT_H__CA6BC29E_FAC2_11D1_A0DE_000000000000__INCLUDED_
7
8
#ifdef _MSC_VER
9
#pragma once
10
#endif
// _MSC_VER
11
12
#include "
Point.h
"
13
14
BEGIN_MOOTOOLS_NAMESPACE
15
16
class
DLL_3DFUNCTION
C4DPoint
17
{
18
public
:
19
int
size;
20
double
value[4];
21
22
public
:
23
C4DPoint
();
24
C4DPoint
(
int
size,
bool
init);
25
C4DPoint
(
const
C4DPoint
&
pt
);
26
void
Init(
int
size = 4);
27
28
C4DPoint
& operator=(
const
C4DPoint
&
pt
);
29
void
operator+=(
const
C4DPoint
&
pt
);
30
void
operator-=(
const
C4DPoint
&
pt
);
31
void
operator/=(
const
C4DPoint
&
pt
);
32
void
operator/=(
double
val);
33
void
operator*=(
const
C4DPoint
&
pt
);
34
C4DPoint
operator+(
const
C4DPoint
&
pt
);
35
C4DPoint
operator-(
const
C4DPoint
&
pt
);
36
C4DPoint
operator/(
const
C4DPoint
&
pt
);
37
C4DPoint
operator/(
double
val);
38
C4DPoint
operator*(
const
C4DPoint
&
pt
);
39
};
40
41
template
<>
class
CHashMethods
<
C4DPoint
>
42
{
43
public
:
44
static
inline
bool
HashCompare(
const
C4DPoint
&
pt1
,
const
C4DPoint
&
pt2
)
45
{
46
if
(
pt1
.size !=
pt2
.size)
47
return
false
;
48
49
for
(
int
i
= 0;
i
<
pt1
.size;
i
++)
50
{
51
if
(
pt1
.value[
i
] !=
pt2
.value[
i
])
52
return
false
;
53
}
54
55
return
true
;
56
}
57
58
static
inline
unsigned
int
HashValue(
const
C4DPoint
&
pt
)
59
{
60
// Used for hashing purpose
61
int
val = 0;
62
for
(
int
i
= 0;
i
<
pt
.size;
i
++)
63
val +=
CHashMethods<double>::HashValue
(
pt
.value[
i
]);
64
65
return
val;
66
}
67
};
68
69
inline
C4DPoint::C4DPoint()
70
{
71
Init(4);
// Set all value to 0.0
72
size = 0;
73
}
74
75
inline
C4DPoint::C4DPoint(
int
size,
bool
init)
76
{
77
this->size = size;
78
if
(init)
79
Init(size);
80
}
81
82
inline
C4DPoint
& C4DPoint::operator=(
const
C4DPoint
&
pt
)
83
{
84
this->size =
pt
.size;
85
for
(
int
i
= 0;
i
<size;
i
++)
86
this->value[
i
] =
pt
.value[
i
];
87
88
return
*
this
;
89
}
90
91
inline
void
C4DPoint::operator+=(
const
C4DPoint
&
pt
)
92
{
93
XASSERT(size ==
pt
.size);
94
for
(
int
i
= 0;
i
<size;
i
++)
95
this->value[
i
] +=
pt
.value[
i
];
96
}
97
98
inline
void
C4DPoint::operator-=(
const
C4DPoint
&
pt
)
99
{
100
XASSERT(size ==
pt
.size);
101
for
(
int
i
= 0;
i
<size;
i
++)
102
this->value[
i
] -=
pt
.value[
i
];
103
}
104
105
inline
void
C4DPoint::operator/=(
const
C4DPoint
&
pt
)
106
{
107
XASSERT(size ==
pt
.size);
108
for
(
int
i
= 0;
i
<size;
i
++)
109
this->value[
i
] /=
pt
.value[
i
];
110
}
111
112
inline
void
C4DPoint::operator/=(
double
val)
113
{
114
for
(
int
i
= 0;
i
<size;
i
++)
115
this->value[
i
] /= val;
116
}
117
118
inline
void
C4DPoint::operator*=(
const
C4DPoint
&
pt
)
119
{
120
XASSERT(size ==
pt
.size);
121
for
(
int
i
= 0;
i
<size;
i
++)
122
this->value[
i
] *=
pt
.value[
i
];
123
}
124
125
126
inline
C4DPoint
C4DPoint::operator+(
const
C4DPoint
&
pt
)
127
{
128
XASSERT(size ==
pt
.size);
129
C4DPoint
tmp
(
pt
.size,
FALSE
);
130
for
(
int
i
= 0;
i
<size;
i
++)
131
tmp
.value[
i
] = value[
i
] +
pt
.value[
i
];
132
133
return
tmp
;
134
}
135
136
inline
C4DPoint
C4DPoint::operator-(
const
C4DPoint
&
pt
)
137
{
138
XASSERT(size ==
pt
.size);
139
C4DPoint
tmp
(
pt
.size,
FALSE
);
140
for
(
int
i
= 0;
i
<size;
i
++)
141
tmp
.value[
i
] = value[
i
] -
pt
.value[
i
];
142
143
return
tmp
;
144
}
145
146
inline
C4DPoint
C4DPoint::operator/(
const
C4DPoint
&
pt
)
147
{
148
XASSERT(size ==
pt
.size);
149
C4DPoint
tmp
(
pt
.size,
FALSE
);
150
for
(
int
i
= 0;
i
<size;
i
++)
151
tmp
.value[
i
] = value[
i
] /
pt
.value[
i
];
152
153
return
tmp
;
154
}
155
156
inline
C4DPoint
C4DPoint::operator/(
double
val)
157
{
158
C4DPoint
tmp
(size,
FALSE
);
159
for
(
int
i
= 0;
i
<size;
i
++)
160
tmp
.value[
i
] = value[
i
] / val;
161
162
return
tmp
;
163
}
164
165
inline
C4DPoint
C4DPoint::operator*(
const
C4DPoint
&
pt
)
166
{
167
XASSERT(size ==
pt
.size);
168
C4DPoint
tmp
(
pt
.size,
FALSE
);
169
for
(
int
i
= 0;
i
<size;
i
++)
170
tmp
.value[
i
] = value[
i
] *
pt
.value[
i
];
171
172
return
tmp
;
173
}
174
175
END_MOOTOOLS_NAMESPACE
176
177
#endif
// !defined(AFX_4DPOINT_H__CA6BC29E_FAC2_11D1_A0DE_000000000000__INCLUDED_)
Point.h
CPt class is the base class for different class of points (C3DPoint, CUVWPoint...)
C3DTPoint
The class defines an x, y, z 3D point which can use int, float or double.
Definition
3DPoint.h:27
C4DPoint
Definition
4DPoint.h:17
CHashMethods
Definition
Hash.h:146
VS2022-PolygonCruncherSDK-Full-IO
SDK
Includes
4DPoint.h
Generated by
1.9.8