7 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
8 # if GLM_HAS_UNRESTRICTED_UNIONS
18 template<
typename T, qualifier Q>
24 typedef vec<4, T, Q> type;
25 typedef vec<4, bool, Q> bool_type;
29 # if GLM_HAS_ONLY_XYZW
32 # elif GLM_HAS_ALIGNED_TYPE
33 # if GLM_COMPILER & GLM_COMPILER_GCC
34 # pragma GCC diagnostic push
35 # pragma GCC diagnostic ignored "-Wpedantic"
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"
45 struct { T x, y, z, w;};
46 struct { T r, g, b, a; };
47 struct { T s, t, p, q; };
49 typename detail::storage<T, sizeof(T) * 4, detail::is_aligned<Q>::value>::type data;
51 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
52 GLM_SWIZZLE4_2_MEMBERS(T, Q, x, y, z, w)
53 GLM_SWIZZLE4_2_MEMBERS(T, Q, r, g, b, a)
54 GLM_SWIZZLE4_2_MEMBERS(T, Q, s, t, p, q)
55 GLM_SWIZZLE4_3_MEMBERS(T, Q, x, y, z, w)
56 GLM_SWIZZLE4_3_MEMBERS(T, Q, r, g, b, a)
57 GLM_SWIZZLE4_3_MEMBERS(T, Q, s, t, p, q)
58 GLM_SWIZZLE4_4_MEMBERS(T, Q, x, y, z, w)
59 GLM_SWIZZLE4_4_MEMBERS(T, Q, r, g, b, a)
60 GLM_SWIZZLE4_4_MEMBERS(T, Q, s, t, p, q)
64 # if GLM_COMPILER & GLM_COMPILER_CLANG
65 # pragma clang diagnostic pop
67 # if GLM_COMPILER & GLM_COMPILER_GCC
68 # pragma GCC diagnostic pop
76 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
77 GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P)
84 typedef length_t length_type;
85 GLM_FUNC_DECL
static GLM_CONSTEXPR length_type
length(){
return 4;}
87 GLM_FUNC_DECL T & operator[](length_type i);
88 GLM_FUNC_DECL T
const& operator[](length_type i)
const;
92 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec() GLM_DEFAULT_CTOR;
93 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, Q> const& v) GLM_DEFAULT;
95 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(vec<4, T, P> const& v);
99 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD explicit vec(T scalar);
100 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(T x, T y, T z, T w);
105 template<typename X, typename Y, typename Z, typename W>
106 GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(X _x, Y _y, Z _z, W _w);
107 template<typename X, typename Y, typename Z, typename W>
108 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, vec<1, W, Q> const& _w);
113 template<typename A, typename B, typename C, qualifier P>
114 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, P> const& _xy, B _z, C _w);
116 template<typename A, typename B, typename C, qualifier P>
117 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, P> const& _xy, vec<1, B, P> const& _z, vec<1, C, P> const& _w);
119 template<typename A, typename B, typename C, qualifier P>
120 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, vec<2, B, P> const& _yz, C _w);
122 template<typename A, typename B, typename C, qualifier P>
123 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, P> const& _x, vec<2, B, P> const& _yz, vec<1, C, P> const& _w);
125 template<typename A, typename B, typename C, qualifier P>
126 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, B _y, vec<2, C, P> const& _zw);
128 template<typename A, typename B, typename C, qualifier P>
129 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, P> const& _x, vec<1, B, P> const& _y, vec<2, C, P> const& _zw);
131 template<typename A, typename B, qualifier P>
132 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, A, P> const& _xyz, B _w);
134 template<typename A, typename B, qualifier P>
135 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<3, A, P> const& _xyz, vec<1, B, P> const& _w);
137 template<typename A, typename B, qualifier P>
138 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A _x, vec<3, B, P> const& _yzw);
140 template<typename A, typename B, qualifier P>
141 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, P> const& _x, vec<3, B, P> const& _yzw);
143 template<typename A, typename B, qualifier P>
144 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<2, A, P> const& _xy, vec<2, B, P> const& _zw);
147 template<typename U, qualifier P>
148 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR GLM_EXPLICIT vec(vec<4, U, P> const& v);
151 # if GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
152 template<
int E0,
int E1,
int E2,
int E3>
153 GLM_FUNC_DECL vec(detail::_swizzle<4, T, Q, E0, E1, E2, E3>
const& that)
158 template<
int E0,
int E1,
int F0,
int F1>
159 GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1, -1, -2>
const& v, detail::_swizzle<2, T, Q, F0, F1, -1, -2>
const& u)
161 *
this = vec<4, T, Q>(v(), u());
164 template<
int E0,
int E1>
165 GLM_FUNC_DECL vec(T
const& x, T
const& y, detail::_swizzle<2, T, Q, E0, E1, -1, -2>
const& v)
167 *
this = vec<4, T, Q>(x, y, v());
170 template<
int E0,
int E1>
171 GLM_FUNC_DECL vec(T
const& x, detail::_swizzle<2, T, Q, E0, E1, -1, -2>
const& v, T
const& w)
173 *
this = vec<4, T, Q>(x, v(), w);
176 template<
int E0,
int E1>
177 GLM_FUNC_DECL vec(detail::_swizzle<2, T, Q, E0, E1, -1, -2>
const& v, T
const& z, T
const& w)
179 *
this = vec<4, T, Q>(v(), z, w);
182 template<
int E0,
int E1,
int E2>
183 GLM_FUNC_DECL vec(detail::_swizzle<3, T, Q, E0, E1, E2, -1>
const& v, T
const& w)
185 *
this = vec<4, T, Q>(v(), w);
188 template<
int E0,
int E1,
int E2>
189 GLM_FUNC_DECL vec(T
const& x, detail::_swizzle<3, T, Q, E0, E1, E2, -1>
const& v)
191 *
this = vec<4, T, Q>(x, v());
193 # endif// GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)
197 GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<4, T, Q>& operator=(vec<4, T, Q>
const& v) GLM_DEFAULT;
200 GLM_FUNC_DECL GLM_CONSTEXPR_CXX14 vec<4, T, Q>& operator=(vec<4, U, Q>
const& v);
202 GLM_FUNC_DECL vec<4, T, Q>& operator+=(U scalar);
204 GLM_FUNC_DECL vec<4, T, Q>& operator+=(vec<1, U, Q>
const& v);
206 GLM_FUNC_DECL vec<4, T, Q>& operator+=(vec<4, U, Q>
const& v);
208 GLM_FUNC_DECL vec<4, T, Q>& operator-=(U scalar);
210 GLM_FUNC_DECL vec<4, T, Q>& operator-=(vec<1, U, Q>
const& v);
212 GLM_FUNC_DECL vec<4, T, Q>& operator-=(vec<4, U, Q>
const& v);
214 GLM_FUNC_DECL vec<4, T, Q>& operator*=(U scalar);
216 GLM_FUNC_DECL vec<4, T, Q>& operator*=(vec<1, U, Q>
const& v);
218 GLM_FUNC_DECL vec<4, T, Q>& operator*=(vec<4, U, Q>
const& v);
220 GLM_FUNC_DECL vec<4, T, Q>& operator/=(U scalar);
222 GLM_FUNC_DECL vec<4, T, Q>& operator/=(vec<1, U, Q>
const& v);
224 GLM_FUNC_DECL vec<4, T, Q>& operator/=(vec<4, U, Q>
const& v);
228 GLM_FUNC_DECL vec<4, T, Q> & operator++();
229 GLM_FUNC_DECL vec<4, T, Q> & operator--();
230 GLM_FUNC_DECL vec<4, T, Q> operator++(
int);
231 GLM_FUNC_DECL vec<4, T, Q> operator--(
int);
236 GLM_FUNC_DECL vec<4, T, Q> & operator%=(U scalar);
238 GLM_FUNC_DECL vec<4, T, Q> & operator%=(vec<1, U, Q>
const& v);
240 GLM_FUNC_DECL vec<4, T, Q> & operator%=(vec<4, U, Q>
const& v);
242 GLM_FUNC_DECL vec<4, T, Q> & operator&=(U scalar);
244 GLM_FUNC_DECL vec<4, T, Q> & operator&=(vec<1, U, Q>
const& v);
246 GLM_FUNC_DECL vec<4, T, Q> & operator&=(vec<4, U, Q>
const& v);
248 GLM_FUNC_DECL vec<4, T, Q> & operator|=(U scalar);
250 GLM_FUNC_DECL vec<4, T, Q> & operator|=(vec<1, U, Q>
const& v);
252 GLM_FUNC_DECL vec<4, T, Q> & operator|=(vec<4, U, Q>
const& v);
254 GLM_FUNC_DECL vec<4, T, Q> & operator^=(U scalar);
256 GLM_FUNC_DECL vec<4, T, Q> & operator^=(vec<1, U, Q>
const& v);
258 GLM_FUNC_DECL vec<4, T, Q> & operator^=(vec<4, U, Q>
const& v);
260 GLM_FUNC_DECL vec<4, T, Q> & operator<<=(U scalar);
262 GLM_FUNC_DECL vec<4, T, Q> & operator<<=(vec<1, U, Q>
const& v);
264 GLM_FUNC_DECL vec<4, T, Q> & operator<<=(vec<4, U, Q>
const& v);
266 GLM_FUNC_DECL vec<4, T, Q> & operator>>=(U scalar);
268 GLM_FUNC_DECL vec<4, T, Q> & operator>>=(vec<1, U, Q>
const& v);
270 GLM_FUNC_DECL vec<4, T, Q> & operator>>=(vec<4, U, Q>
const& v);
275 template<
typename T, qualifier Q>
276 GLM_FUNC_DECL vec<4, T, Q> operator+(vec<4, T, Q>
const& v);
278 template<
typename T, qualifier Q>
279 GLM_FUNC_DECL vec<4, T, Q> operator-(vec<4, T, Q>
const& v);
283 template<
typename T, qualifier Q>
284 GLM_FUNC_DECL vec<4, T, Q> operator+(vec<4, T, Q>
const& v, T
const & scalar);
286 template<
typename T, qualifier Q>
287 GLM_FUNC_DECL vec<4, T, Q> operator+(vec<4, T, Q>
const& v1, vec<1, T, Q>
const& v2);
289 template<
typename T, qualifier Q>
290 GLM_FUNC_DECL vec<4, T, Q> operator+(T scalar, vec<4, T, Q>
const& v);
292 template<
typename T, qualifier Q>
293 GLM_FUNC_DECL vec<4, T, Q> operator+(vec<1, T, Q>
const& v1, vec<4, T, Q>
const& v2);
295 template<
typename T, qualifier Q>
296 GLM_FUNC_DECL vec<4, T, Q> operator+(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
298 template<
typename T, qualifier Q>
299 GLM_FUNC_DECL vec<4, T, Q> operator-(vec<4, T, Q>
const& v, T
const & scalar);
301 template<
typename T, qualifier Q>
302 GLM_FUNC_DECL vec<4, T, Q> operator-(vec<4, T, Q>
const& v1, vec<1, T, Q>
const& v2);
304 template<
typename T, qualifier Q>
305 GLM_FUNC_DECL vec<4, T, Q> operator-(T scalar, vec<4, T, Q>
const& v);
307 template<
typename T, qualifier Q>
308 GLM_FUNC_DECL vec<4, T, Q> operator-(vec<1, T, Q>
const& v1, vec<4, T, Q>
const& v2);
310 template<
typename T, qualifier Q>
311 GLM_FUNC_DECL vec<4, T, Q> operator-(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
313 template<
typename T, qualifier Q>
314 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q>
const& v, T
const & scalar);
316 template<
typename T, qualifier Q>
317 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q>
const& v1, vec<1, T, Q>
const& v2);
319 template<
typename T, qualifier Q>
320 GLM_FUNC_DECL vec<4, T, Q> operator*(T scalar, vec<4, T, Q>
const& v);
322 template<
typename T, qualifier Q>
323 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<1, T, Q>
const& v1, vec<4, T, Q>
const& v2);
325 template<
typename T, qualifier Q>
326 GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
328 template<
typename T, qualifier Q>
329 GLM_FUNC_DECL vec<4, T, Q> operator/(vec<4, T, Q>
const& v, T
const & scalar);
331 template<
typename T, qualifier Q>
332 GLM_FUNC_DECL vec<4, T, Q> operator/(vec<4, T, Q>
const& v1, vec<1, T, Q>
const& v2);
334 template<
typename T, qualifier Q>
335 GLM_FUNC_DECL vec<4, T, Q> operator/(T scalar, vec<4, T, Q>
const& v);
337 template<
typename T, qualifier Q>
338 GLM_FUNC_DECL vec<4, T, Q> operator/(vec<1, T, Q>
const& v1, vec<4, T, Q>
const& v2);
340 template<
typename T, qualifier Q>
341 GLM_FUNC_DECL vec<4, T, Q> operator/(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
343 template<
typename T, qualifier Q>
344 GLM_FUNC_DECL vec<4, T, Q> operator%(vec<4, T, Q>
const& v, T scalar);
346 template<
typename T, qualifier Q>
347 GLM_FUNC_DECL vec<4, T, Q> operator%(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
349 template<
typename T, qualifier Q>
350 GLM_FUNC_DECL vec<4, T, Q> operator%(T scalar, vec<4, T, Q>
const& v);
352 template<
typename T, qualifier Q>
353 GLM_FUNC_DECL vec<4, T, Q> operator%(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
355 template<
typename T, qualifier Q>
356 GLM_FUNC_DECL vec<4, T, Q> operator%(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
358 template<
typename T, qualifier Q>
359 GLM_FUNC_DECL vec<4, T, Q> operator&(vec<4, T, Q>
const& v, T scalar);
361 template<
typename T, qualifier Q>
362 GLM_FUNC_DECL vec<4, T, Q> operator&(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
364 template<
typename T, qualifier Q>
365 GLM_FUNC_DECL vec<4, T, Q> operator&(T scalar, vec<4, T, Q>
const& v);
367 template<
typename T, qualifier Q>
368 GLM_FUNC_DECL vec<4, T, Q> operator&(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
370 template<
typename T, qualifier Q>
371 GLM_FUNC_DECL vec<4, T, Q> operator&(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
373 template<
typename T, qualifier Q>
374 GLM_FUNC_DECL vec<4, T, Q> operator|(vec<4, T, Q>
const& v, T scalar);
376 template<
typename T, qualifier Q>
377 GLM_FUNC_DECL vec<4, T, Q> operator|(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
379 template<
typename T, qualifier Q>
380 GLM_FUNC_DECL vec<4, T, Q> operator|(T scalar, vec<4, T, Q>
const& v);
382 template<
typename T, qualifier Q>
383 GLM_FUNC_DECL vec<4, T, Q> operator|(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
385 template<
typename T, qualifier Q>
386 GLM_FUNC_DECL vec<4, T, Q> operator|(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
388 template<
typename T, qualifier Q>
389 GLM_FUNC_DECL vec<4, T, Q> operator^(vec<4, T, Q>
const& v, T scalar);
391 template<
typename T, qualifier Q>
392 GLM_FUNC_DECL vec<4, T, Q> operator^(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
394 template<
typename T, qualifier Q>
395 GLM_FUNC_DECL vec<4, T, Q> operator^(T scalar, vec<4, T, Q>
const& v);
397 template<
typename T, qualifier Q>
398 GLM_FUNC_DECL vec<4, T, Q> operator^(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
400 template<
typename T, qualifier Q>
401 GLM_FUNC_DECL vec<4, T, Q> operator^(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
403 template<
typename T, qualifier Q>
404 GLM_FUNC_DECL vec<4, T, Q> operator<<(vec<4, T, Q>
const& v, T scalar);
406 template<
typename T, qualifier Q>
407 GLM_FUNC_DECL vec<4, T, Q> operator<<(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
409 template<
typename T, qualifier Q>
410 GLM_FUNC_DECL vec<4, T, Q> operator<<(T scalar, vec<4, T, Q>
const& v);
412 template<
typename T, qualifier Q>
413 GLM_FUNC_DECL vec<4, T, Q> operator<<(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
415 template<
typename T, qualifier Q>
416 GLM_FUNC_DECL vec<4, T, Q> operator<<(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
418 template<
typename T, qualifier Q>
419 GLM_FUNC_DECL vec<4, T, Q> operator>>(vec<4, T, Q>
const& v, T scalar);
421 template<
typename T, qualifier Q>
422 GLM_FUNC_DECL vec<4, T, Q> operator>>(vec<4, T, Q>
const& v, vec<1, T, Q>
const& scalar);
424 template<
typename T, qualifier Q>
425 GLM_FUNC_DECL vec<4, T, Q> operator>>(T scalar, vec<4, T, Q>
const& v);
427 template<
typename T, qualifier Q>
428 GLM_FUNC_DECL vec<4, T, Q> operator>>(vec<1, T, Q>
const& scalar, vec<4, T, Q>
const& v);
430 template<
typename T, qualifier Q>
431 GLM_FUNC_DECL vec<4, T, Q> operator>>(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
433 template<
typename T, qualifier Q>
434 GLM_FUNC_DECL vec<4, T, Q> operator~(vec<4, T, Q>
const& v);
438 template<
typename T, qualifier Q>
439 GLM_FUNC_DECL
bool operator==(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
441 template<
typename T, qualifier Q>
442 GLM_FUNC_DECL
bool operator!=(vec<4, T, Q>
const& v1, vec<4, T, Q>
const& v2);
444 template<qualifier Q>
445 GLM_FUNC_DECL vec<4, bool, Q> operator&&(vec<4, bool, Q>
const& v1, vec<4, bool, Q>
const& v2);
447 template<qualifier Q>
448 GLM_FUNC_DECL vec<4, bool, Q> operator||(vec<4, bool, Q>
const& v1, vec<4, bool, Q>
const& v2);
451 #ifndef GLM_EXTERNAL_TEMPLATE
452 #include "type_vec4.inl"
453 #endif//GLM_EXTERNAL_TEMPLATE
GLM_FUNC_DECL T length(vec< L, T, Q > const &x)
Returns the length of x, i.e., sqrt(x * x).