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