| 0.9.9 API documenation

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