FTGL 2.4.0
FTPoint.h
Go to the documentation of this file.
1/*
2 * FTGL - OpenGL font library
3 *
4 * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
5 * Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
6 * Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#ifndef __ftgl__
29# warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
30# include <FTGL/ftgl.h>
31#endif
32
33#ifndef __FTPoint__
34#define __FTPoint__
35
36#ifdef __cplusplus
37
38
43{
44 public:
48 inline FTPoint()
49 {
50 values[0] = 0;
51 values[1] = 0;
52 values[2] = 0;
53 }
54
62 inline FTPoint(const FTGL_DOUBLE x, const FTGL_DOUBLE y,
63 const FTGL_DOUBLE z = 0)
64 {
65 values[0] = x;
66 values[1] = y;
67 values[2] = z;
68 }
69
75 inline FTPoint(const FT_Vector& ft_vector)
76 {
77 values[0] = ft_vector.x;
78 values[1] = ft_vector.y;
79 values[2] = 0;
80 }
81
89
90
97 inline FTPoint& operator += (const FTPoint& point)
98 {
99 values[0] += point.values[0];
100 values[1] += point.values[1];
101 values[2] += point.values[2];
102
103 return *this;
104 }
105
112 inline FTPoint operator + (const FTPoint& point) const
113 {
114 FTPoint temp;
115 temp.values[0] = values[0] + point.values[0];
116 temp.values[1] = values[1] + point.values[1];
117 temp.values[2] = values[2] + point.values[2];
118
119 return temp;
120 }
121
128 inline FTPoint& operator -= (const FTPoint& point)
129 {
130 values[0] -= point.values[0];
131 values[1] -= point.values[1];
132 values[2] -= point.values[2];
133
134 return *this;
135 }
136
143 inline FTPoint operator - (const FTPoint& point) const
144 {
145 FTPoint temp;
146 temp.values[0] = values[0] - point.values[0];
147 temp.values[1] = values[1] - point.values[1];
148 temp.values[2] = values[2] - point.values[2];
149
150 return temp;
151 }
152
159 inline FTPoint operator * (double multiplier) const
160 {
161 FTPoint temp;
162 temp.values[0] = values[0] * multiplier;
163 temp.values[1] = values[1] * multiplier;
164 temp.values[2] = values[2] * multiplier;
165
166 return temp;
167 }
168
169
177 inline friend FTPoint operator * (double multiplier, FTPoint& point)
178 {
179 return point * multiplier;
180 }
181
182
190 inline friend double operator * (FTPoint &a, FTPoint& b)
191 {
192 return a.values[0] * b.values[0]
193 + a.values[1] * b.values[1]
194 + a.values[2] * b.values[2];
195 }
196
197
204 inline FTPoint operator ^ (const FTPoint& point)
205 {
206 FTPoint temp;
207 temp.values[0] = values[1] * point.values[2]
208 - values[2] * point.values[1];
209 temp.values[1] = values[2] * point.values[0]
210 - values[0] * point.values[2];
211 temp.values[2] = values[0] * point.values[1]
212 - values[1] * point.values[0];
213 return temp;
214 }
215
216
224 friend bool operator == (const FTPoint &a, const FTPoint &b);
225
226
234 friend bool operator != (const FTPoint &a, const FTPoint &b);
235
236
240 inline operator const FTGL_DOUBLE*() const
241 {
242 return values;
243 }
244
245
249 inline void X(FTGL_DOUBLE x) { values[0] = x; };
250 inline void Y(FTGL_DOUBLE y) { values[1] = y; };
251 inline void Z(FTGL_DOUBLE z) { values[2] = z; };
252
253
257 inline FTGL_DOUBLE X() const { return values[0]; };
258 inline FTGL_DOUBLE Y() const { return values[1]; };
259 inline FTGL_DOUBLE Z() const { return values[2]; };
260 inline FTGL_FLOAT Xf() const { return static_cast<FTGL_FLOAT>(values[0]); };
261 inline FTGL_FLOAT Yf() const { return static_cast<FTGL_FLOAT>(values[1]); };
262 inline FTGL_FLOAT Zf() const { return static_cast<FTGL_FLOAT>(values[2]); };
263
264 private:
268 FTGL_DOUBLE values[3];
269};
270
271#endif //__cplusplus
272
273#endif // __FTPoint__
274
FTPoint class is a basic 3-dimensional point or vector.
Definition FTPoint.h:43
void Y(FTGL_DOUBLE y)
Definition FTPoint.h:250
void Z(FTGL_DOUBLE z)
Definition FTPoint.h:251
FTGL_FLOAT Yf() const
Definition FTPoint.h:261
FTPoint(const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z=0)
Constructor.
Definition FTPoint.h:62
FTGL_FLOAT Xf() const
Definition FTPoint.h:260
FTPoint()
Default constructor.
Definition FTPoint.h:48
FTGL_DOUBLE X() const
Getters.
Definition FTPoint.h:257
FTGL_FLOAT Zf() const
Definition FTPoint.h:262
FTPoint Normalise()
Normalise a point's coordinates.
FTGL_DOUBLE Y() const
Definition FTPoint.h:258
FTPoint(const FT_Vector &ft_vector)
Constructor.
Definition FTPoint.h:75
FTGL_DOUBLE Z() const
Definition FTPoint.h:259
void X(FTGL_DOUBLE x)
Setters.
Definition FTPoint.h:249
float FTGL_FLOAT
Definition ftgl.h:39
#define FTGL_EXPORT
Definition ftgl.h:134
double FTGL_DOUBLE
Definition ftgl.h:38