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
14BEGIN_MOOTOOLS_NAMESPACE
15
16class DLL_3DFUNCTION C4DPoint
17{
18public:
19 int size;
20 double value[4];
21
22public:
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
41template <> class CHashMethods<C4DPoint>
42{
43public:
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++)
64
65 return val;
66 }
67};
68
69inline C4DPoint::C4DPoint()
70{
71 Init(4); // Set all value to 0.0
72 size = 0;
73}
74
75inline C4DPoint::C4DPoint(int size, bool init)
76{
77 this->size = size;
78 if (init)
79 Init(size);
80}
81
82inline 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
91inline 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
98inline 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
105inline 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
112inline void C4DPoint::operator/=(double val)
113{
114 for (int i = 0; i<size; i++)
115 this->value[i] /= val;
116}
117
118inline 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
126inline 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
136inline 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
146inline 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
156inline 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
165inline 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
175END_MOOTOOLS_NAMESPACE
176
177#endif // !defined(AFX_4DPOINT_H__CA6BC29E_FAC2_11D1_A0DE_000000000000__INCLUDED_)
CPt class is the base class for different class of points (C3DPoint, CUVWPoint...)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition 4DPoint.h:17
Definition Hash.h:146