0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

type_vec3.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #include "type_vec.hpp"
7 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
8 # if GLM_HAS_UNRESTRICTED_UNIONS
9 # include "_swizzle.hpp"
10 # else
11 # include "_swizzle_func.hpp"
12 # endif
13 #endif //GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
14 #include <cstddef>
15
16 namespace glm
17 {
18 template<typename T, qualifier Q>
19 struct vec<3, T, Q>
20 {
21 // -- Implementation detail --
22
23 typedef T value_type;
24 typedef vec type;
25 typedef vec<3, bool, Q> bool_type;
26
27 // -- Data --
28
29 # if GLM_HAS_ONLY_XYZW
30 T x, y, z;
31
32 # elif GLM_HAS_ALIGNED_TYPE
33 # if GLM_COMPILER & GLM_COMPILER_GCC
34 # pragma GCC diagnostic push
35 # pragma GCC diagnostic ignored "-Wpedantic"
36 # endif
37 # if GLM_COMPILER & GLM_COMPILER_CLANG
38 # pragma clang diagnostic push
39 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
40 # pragma clang diagnostic ignored "-Wnested-anon-types"
41 # endif
42
43 union
44 {
45 struct{ T x, y, z; };
46 struct{ T r, g, b; };
47 struct{ T s, t, p; };
48
49 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
50 GLM_SWIZZLE3_2_MEMBERS(T, Q, x, y, z)
51 GLM_SWIZZLE3_2_MEMBERS(T, Q, r, g, b)
52 GLM_SWIZZLE3_2_MEMBERS(T, Q, s, t, p)
53 GLM_SWIZZLE3_3_MEMBERS(T, Q, x, y, z)
54 GLM_SWIZZLE3_3_MEMBERS(T, Q, r, g, b)
55 GLM_SWIZZLE3_3_MEMBERS(T, Q, s, t, p)
56 GLM_SWIZZLE3_4_MEMBERS(T, Q, x, y, z)
57 GLM_SWIZZLE3_4_MEMBERS(T, Q, r, g, b)
58 GLM_SWIZZLE3_4_MEMBERS(T, Q, s, t, p)
59 # endif//GLM_SWIZZLE
60 };
61
62 # if GLM_COMPILER & GLM_COMPILER_CLANG
63 # pragma clang diagnostic pop
64 # endif
65 # if GLM_COMPILER & GLM_COMPILER_GCC
66 # pragma GCC diagnostic pop
67 # endif
68 # else
69 union { T x, r, s; };
70 union { T y, g, t; };
71 union { T z, b, p; };
72
73 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
74 GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P)
75 # endif//GLM_SWIZZLE
76 # endif//GLM_LANG
77
78 // -- Component accesses --
79
81 typedef length_t length_type;
82 GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 3;}
83
84 GLM_FUNC_DECL T & operator[](length_type i);
85 GLM_FUNC_DECL T const& operator[](length_type i) const;
86
87 // -- Implicit basic constructors --
88
89 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec() GLM_DEFAULT;
90 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec const& v) GLM_DEFAULT;
91 template<qualifier P>
92 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, T, P> const& v);
93
94 // -- Explicit basic constructors --
95
96 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(T scalar);
97 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(T a, T b, T c);
98
99 // -- Conversion scalar constructors --
100
102 template<typename X, typename Y, typename Z>
103 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X x, Y y, Z z);
104 template<typename X, typename Y, typename Z>
105 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z);
106
107 // -- Conversion vector constructors --
108
110 template<typename A, typename B, qualifier P>
111 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, P> const& _xy, B _z);
113 template<typename A, typename B, qualifier P>
114 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z);
116 template<typename A, typename B, qualifier P>
117 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, vec<2, B, P> const& _yz);
119 template<typename A, typename B, qualifier P>
120 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz);
122 template<typename U, qualifier P>
123 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<4, U, P> const& v);
124
126 template<typename U, qualifier P>
127 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<3, U, P> const& v);
128
129 // -- Swizzle constructors --
130 # if GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
131 template<int E0, int E1, int E2>
132 GLM_FUNC_DECL vec(detail::_swizzle<3, T, Q, E0, E1, E2, -1> const& that)
133 {
134 *this = that();
135 }
136
137 template<int E0, int E1>
138 GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1, -1, -2> const& v, T const& scalar)
139 {
140 *this = vec(v(), scalar);
141 }
142
143 template<int E0, int E1>
144 GLM_FUNC_DECL vec(T const& scalar, detail::_swizzle<2, T, Q, E0, E1, -1, -2> const& v)
145 {
146 *this = vec(scalar, v());
147 }
148 # endif// GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
149
150 // -- Unary arithmetic operators --
151
152 GLM_FUNC_DECL vec & operator=(vec const& v) GLM_DEFAULT;
153
154 template<typename U>
155 GLM_FUNC_DECL vec & operator=(vec<3, U, Q> const& v);
156 template<typename U>
157 GLM_FUNC_DECL vec & operator+=(U scalar);
158 template<typename U>
159 GLM_FUNC_DECL vec & operator+=(vec<1, U, Q> const& v);
160 template<typename U>
161 GLM_FUNC_DECL vec & operator+=(vec<3, U, Q> const& v);
162 template<typename U>
163 GLM_FUNC_DECL vec & operator-=(U scalar);
164 template<typename U>
165 GLM_FUNC_DECL vec & operator-=(vec<1, U, Q> const& v);
166 template<typename U>
167 GLM_FUNC_DECL vec & operator-=(vec<3, U, Q> const& v);
168 template<typename U>
169 GLM_FUNC_DECL vec & operator*=(U scalar);
170 template<typename U>
171 GLM_FUNC_DECL vec & operator*=(vec<1, U, Q> const& v);
172 template<typename U>
173 GLM_FUNC_DECL vec & operator*=(vec<3, U, Q> const& v);
174 template<typename U>
175 GLM_FUNC_DECL vec & operator/=(U scalar);
176 template<typename U>
177 GLM_FUNC_DECL vec & operator/=(vec<1, U, Q> const& v);
178 template<typename U>
179 GLM_FUNC_DECL vec & operator/=(vec<3, U, Q> const& v);
180
181 // -- Increment and decrement operators --
182
183 GLM_FUNC_DECL vec & operator++();
184 GLM_FUNC_DECL vec & operator--();
185 GLM_FUNC_DECL vec operator++(int);
186 GLM_FUNC_DECL vec operator--(int);
187
188 // -- Unary bit operators --
189
190 template<typename U>
191 GLM_FUNC_DECL vec & operator%=(U scalar);
192 template<typename U>
193 GLM_FUNC_DECL vec & operator%=(vec<1, U, Q> const& v);
194 template<typename U>
195 GLM_FUNC_DECL vec & operator%=(vec<3, U, Q> const& v);
196 template<typename U>
197 GLM_FUNC_DECL vec & operator&=(U scalar);
198 template<typename U>
199 GLM_FUNC_DECL vec & operator&=(vec<1, U, Q> const& v);
200 template<typename U>
201 GLM_FUNC_DECL vec & operator&=(vec<3, U, Q> const& v);
202 template<typename U>
203 GLM_FUNC_DECL vec & operator|=(U scalar);
204 template<typename U>
205 GLM_FUNC_DECL vec & operator|=(vec<1, U, Q> const& v);
206 template<typename U>
207 GLM_FUNC_DECL vec & operator|=(vec<3, U, Q> const& v);
208 template<typename U>
209 GLM_FUNC_DECL vec & operator^=(U scalar);
210 template<typename U>
211 GLM_FUNC_DECL vec & operator^=(vec<1, U, Q> const& v);
212 template<typename U>
213 GLM_FUNC_DECL vec & operator^=(vec<3, U, Q> const& v);
214 template<typename U>
215 GLM_FUNC_DECL vec & operator<<=(U scalar);
216 template<typename U>
217 GLM_FUNC_DECL vec & operator<<=(vec<1, U, Q> const& v);
218 template<typename U>
219 GLM_FUNC_DECL vec & operator<<=(vec<3, U, Q> const& v);
220 template<typename U>
221 GLM_FUNC_DECL vec & operator>>=(U scalar);
222 template<typename U>
223 GLM_FUNC_DECL vec & operator>>=(vec<1, U, Q> const& v);
224 template<typename U>
225 GLM_FUNC_DECL vec & operator>>=(vec<3, U, Q> const& v);
226 };
227
228 // -- Unary operators --
229
230 template<typename T, qualifier Q>
231 GLM_FUNC_DECL vec<3, T, Q> operator+(vec<3, T, Q> const& v);
232
233 template<typename T, qualifier Q>
234 GLM_FUNC_DECL vec<3, T, Q> operator-(vec<3, T, Q> const& v);
235
236 // -- Binary operators --
237
238 template<typename T, qualifier Q>
239 GLM_FUNC_DECL vec<3, T, Q> operator+(vec<3, T, Q> const& v, T scalar);
240
241 template<typename T, qualifier Q>
242 GLM_FUNC_DECL vec<3, T, Q> operator+(vec<3, T, Q> const& v, vec<1, T, Q> const& scalar);
243
244 template<typename T, qualifier Q>
245 GLM_FUNC_DECL vec<3, T, Q> operator+(T scalar, vec<3, T, Q> const& v);
246
247 template<typename T, qualifier Q>
248 GLM_FUNC_DECL vec<3, T, Q> operator+(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
249
250 template<typename T, qualifier Q>
251 GLM_FUNC_DECL vec<3, T, Q> operator+(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
252
253 template<typename T, qualifier Q>
254 GLM_FUNC_DECL vec<3, T, Q> operator-(vec<3, T, Q> const& v, T scalar);
255
256 template<typename T, qualifier Q>
257 GLM_FUNC_DECL vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
258
259 template<typename T, qualifier Q>
260 GLM_FUNC_DECL vec<3, T, Q> operator-(T scalar, vec<3, T, Q> const& v);
261
262 template<typename T, qualifier Q>
263 GLM_FUNC_DECL vec<3, T, Q> operator-(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
264
265 template<typename T, qualifier Q>
266 GLM_FUNC_DECL vec<3, T, Q> operator-(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
267
268 template<typename T, qualifier Q>
269 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, T scalar);
270
271 template<typename T, qualifier Q>
272 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
273
274 template<typename T, qualifier Q>
275 GLM_FUNC_DECL vec<3, T, Q> operator*(T scalar, vec<3, T, Q> const& v);
276
277 template<typename T, qualifier Q>
278 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
279
280 template<typename T, qualifier Q>
281 GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
282
283 template<typename T, qualifier Q>
284 GLM_FUNC_DECL vec<3, T, Q> operator/(vec<3, T, Q> const& v, T scalar);
285
286 template<typename T, qualifier Q>
287 GLM_FUNC_DECL vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
288
289 template<typename T, qualifier Q>
290 GLM_FUNC_DECL vec<3, T, Q> operator/(T scalar, vec<3, T, Q> const& v);
291
292 template<typename T, qualifier Q>
293 GLM_FUNC_DECL vec<3, T, Q> operator/(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
294
295 template<typename T, qualifier Q>
296 GLM_FUNC_DECL vec<3, T, Q> operator/(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
297
298 template<typename T, qualifier Q>
299 GLM_FUNC_DECL vec<3, T, Q> operator%(vec<3, T, Q> const& v, T scalar);
300
301 template<typename T, qualifier Q>
302 GLM_FUNC_DECL vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
303
304 template<typename T, qualifier Q>
305 GLM_FUNC_DECL vec<3, T, Q> operator%(T const& scalar, vec<3, T, Q> const& v);
306
307 template<typename T, qualifier Q>
308 GLM_FUNC_DECL vec<3, T, Q> operator%(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
309
310 template<typename T, qualifier Q>
311 GLM_FUNC_DECL vec<3, T, Q> operator%(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
312
313 template<typename T, qualifier Q>
314 GLM_FUNC_DECL vec<3, T, Q> operator&(vec<3, T, Q> const& v1, T scalar);
315
316 template<typename T, qualifier Q>
317 GLM_FUNC_DECL vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
318
319 template<typename T, qualifier Q>
320 GLM_FUNC_DECL vec<3, T, Q> operator&(T scalar, vec<3, T, Q> const& v);
321
322 template<typename T, qualifier Q>
323 GLM_FUNC_DECL vec<3, T, Q> operator&(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
324
325 template<typename T, qualifier Q>
326 GLM_FUNC_DECL vec<3, T, Q> operator&(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
327
328 template<typename T, qualifier Q>
329 GLM_FUNC_DECL vec<3, T, Q> operator|(vec<3, T, Q> const& v, T scalar);
330
331 template<typename T, qualifier Q>
332 GLM_FUNC_DECL vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
333
334 template<typename T, qualifier Q>
335 GLM_FUNC_DECL vec<3, T, Q> operator|(T scalar, vec<3, T, Q> const& v);
336
337 template<typename T, qualifier Q>
338 GLM_FUNC_DECL vec<3, T, Q> operator|(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
339
340 template<typename T, qualifier Q>
341 GLM_FUNC_DECL vec<3, T, Q> operator|(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
342
343 template<typename T, qualifier Q>
344 GLM_FUNC_DECL vec<3, T, Q> operator^(vec<3, T, Q> const& v, T scalar);
345
346 template<typename T, qualifier Q>
347 GLM_FUNC_DECL vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
348
349 template<typename T, qualifier Q>
350 GLM_FUNC_DECL vec<3, T, Q> operator^(T scalar, vec<3, T, Q> const& v);
351
352 template<typename T, qualifier Q>
353 GLM_FUNC_DECL vec<3, T, Q> operator^(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
354
355 template<typename T, qualifier Q>
356 GLM_FUNC_DECL vec<3, T, Q> operator^(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
357
358 template<typename T, qualifier Q>
359 GLM_FUNC_DECL vec<3, T, Q> operator<<(vec<3, T, Q> const& v, T scalar);
360
361 template<typename T, qualifier Q>
362 GLM_FUNC_DECL vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
363
364 template<typename T, qualifier Q>
365 GLM_FUNC_DECL vec<3, T, Q> operator<<(T scalar, vec<3, T, Q> const& v);
366
367 template<typename T, qualifier Q>
368 GLM_FUNC_DECL vec<3, T, Q> operator<<(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
369
370 template<typename T, qualifier Q>
371 GLM_FUNC_DECL vec<3, T, Q> operator<<(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
372
373 template<typename T, qualifier Q>
374 GLM_FUNC_DECL vec<3, T, Q> operator>>(vec<3, T, Q> const& v, T scalar);
375
376 template<typename T, qualifier Q>
377 GLM_FUNC_DECL vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<1, T, Q> const& v2);
378
379 template<typename T, qualifier Q>
380 GLM_FUNC_DECL vec<3, T, Q> operator>>(T scalar, vec<3, T, Q> const& v);
381
382 template<typename T, qualifier Q>
383 GLM_FUNC_DECL vec<3, T, Q> operator>>(vec<1, T, Q> const& v1, vec<3, T, Q> const& v2);
384
385 template<typename T, qualifier Q>
386 GLM_FUNC_DECL vec<3, T, Q> operator>>(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
387
388 template<typename T, qualifier Q>
389 GLM_FUNC_DECL vec<3, T, Q> operator~(vec<3, T, Q> const& v);
390
391 // -- Boolean operators --
392
393 template<typename T, qualifier Q>
394 GLM_FUNC_DECL bool operator==(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
395
396 template<typename T, qualifier Q>
397 GLM_FUNC_DECL bool operator!=(vec<3, T, Q> const& v1, vec<3, T, Q> const& v2);
398
399 template<qualifier Q>
400 GLM_FUNC_DECL vec<3, bool, Q> operator&&(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2);
401
402 template<qualifier Q>
403 GLM_FUNC_DECL vec<3, bool, Q> operator||(vec<3, bool, Q> const& v1, vec<3, bool, Q> const& v2);
404 }//namespace glm
405
406 #ifndef GLM_EXTERNAL_TEMPLATE
407 #include "type_vec3.inl"
408 #endif//GLM_EXTERNAL_TEMPLATE
glm
Definition: common.hpp:20
glm::length
GLM_FUNC_DECL T length(vec< L, T, Q > const &x)
Returns the length of x, i.e., sqrt(x * x).
_swizzle_func.hpp
Core features
type_vec.hpp
Core features
_swizzle.hpp
Core features