| 0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

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