PSMoveService
type_vec4.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype4
30 #define glm_core_type_gentype4
31 
32 #include "type_vec.hpp"
33 #include "type_float.hpp"
34 #include "type_int.hpp"
35 #include "type_size.hpp"
36 #include "_swizzle.hpp"
37 
38 namespace glm{
39 namespace detail
40 {
41  template <typename T> struct tref2;
42  template <typename T> struct tref3;
43  template <typename T> struct tref4;
44  template <typename T> struct tvec2;
45  template <typename T> struct tvec3;
46 
47  // Basic 4D vector type.
48  // @ingroup core_template
49  template <typename T>
50  struct tvec4
51  {
52  enum ctor{null};
53 
54  typedef T value_type;
55  typedef std::size_t size_type;
56  GLM_FUNC_DECL size_type length() const;
57 
58  typedef tvec4<T> type;
59  typedef tvec4<bool> bool_type;
60 
62  // Data
63 
64 # if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
65  union
66  {
67 # if(defined(GLM_SWIZZLE))
68  _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z, w)
69  _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b, a)
70  _GLM_SWIZZLE4_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p, q)
71  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y, z, w)
72  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g, b, a)
73  _GLM_SWIZZLE4_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t, p, q)
74  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z, w)
75  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b, a)
76  _GLM_SWIZZLE4_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p, q)
77 # endif//(defined(GLM_SWIZZLE))
78 
79  struct{value_type r, g, b, a;};
80  struct{value_type s, t, p, q;};
81  struct{value_type x, y, z, w;};
82  };
83 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
84  union {value_type x, r, s;};
85  union {value_type y, g, t;};
86  union {value_type z, b, p;};
87  union {value_type w, a, q;};
88 
89 # if(defined(GLM_SWIZZLE))
90  // Defines all he swizzle operator as functions
91  GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4)
92  GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4)
93 # endif//(defined(GLM_SWIZZLE))
94 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
95  value_type x, y, z, w;
96 
97 # if(defined(GLM_SWIZZLE))
98  // Defines all he swizzle operator as functions
99  GLM_SWIZZLE_GEN_REF_FROM_VEC4_COMP(T, detail::tvec4, detail::tref2, detail::tref3, detail::tref4, x, y, z, w)
100  GLM_SWIZZLE_GEN_VEC_FROM_VEC4_COMP(T, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z, w)
101 # endif//(defined(GLM_SWIZZLE))
102 # endif//GLM_COMPONENT
103 
105  // Accesses
106 
107  GLM_FUNC_DECL value_type & operator[](size_type i);
108  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
109 
111  // Implicit basic constructors
112 
113  GLM_FUNC_DECL tvec4();
114  GLM_FUNC_DECL tvec4(type const & v);
115 
117  // Explicit basic constructors
118 
119  GLM_FUNC_DECL explicit tvec4(
120  ctor);
121  GLM_FUNC_DECL explicit tvec4(
122  value_type const & s);
123  GLM_FUNC_DECL explicit tvec4(
124  value_type const & s0,
125  value_type const & s1,
126  value_type const & s2,
127  value_type const & s3);
128 
130  // Convertion scalar constructors
131 
133  template <typename U>
134  GLM_FUNC_DECL explicit tvec4(
135  U const & x);
137  template <typename A, typename B, typename C, typename D>
138  GLM_FUNC_DECL explicit tvec4(
139  A const & x,
140  B const & y,
141  C const & z,
142  D const & w);
143 
145  // Convertion vector constructors
146 
148  template <typename A, typename B, typename C>
149  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
151  template <typename A, typename B, typename C>
152  GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
154  template <typename A, typename B, typename C>
155  GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
157  template <typename A, typename B>
158  GLM_FUNC_DECL explicit tvec4(tvec3<A> const & v, B const & s);
160  template <typename A, typename B>
161  GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B> const & v);
163  template <typename A, typename B>
164  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
166  template <typename U>
167  GLM_FUNC_DECL explicit tvec4(tvec4<U> const & v);
168 
169  template <int E0, int E1, int E2, int E3>
170  GLM_FUNC_DECL tvec4(glm::detail::swizzle<4, T, tvec4<T>, E0, E1, E2, E3> const & that)
171  {
172  *this = that();
173  }
174 
175  template <int E0, int E1, int F0, int F1>
176  GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, glm::detail::swizzle<2, T, tvec2<T>, F0, F1, -1, -2> const & u)
177  {
178  *this = tvec4<T>(v(), u());
179  }
180 
181  template <int E0, int E1>
182  GLM_FUNC_DECL tvec4(T const & x, T const & y, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v)
183  {
184  *this = tvec4<T>(x, y, v());
185  }
186 
187  template <int E0, int E1>
188  GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & w)
189  {
190  *this = tvec4<T>(x, v(), w);
191  }
192 
193  template <int E0, int E1>
194  GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & z, T const & w)
195  {
196  *this = tvec4<T>(v(), z, w);
197  }
198 
199  template <int E0, int E1, int E2>
200  GLM_FUNC_DECL tvec4(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & v, T const & w)
201  {
202  *this = tvec4<T>(v(), w);
203  }
204 
205  template <int E0, int E1, int E2>
206  GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & v)
207  {
208  *this = tvec4<T>(x, v());
209  }
210 
212  // Swizzle constructors
213 
214  GLM_FUNC_DECL tvec4(tref4<T> const & r);
215 
217  template <typename A, typename B, typename C>
218  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v, B const & s1, C const & s2);
220  template <typename A, typename B, typename C>
221  GLM_FUNC_DECL explicit tvec4(A const & s1, tref2<B> const & v, C const & s2);
223  template <typename A, typename B, typename C>
224  GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tref2<C> const & v);
226  template <typename A, typename B>
227  GLM_FUNC_DECL explicit tvec4(tref3<A> const & v, B const & s);
229  template <typename A, typename B>
230  GLM_FUNC_DECL explicit tvec4(A const & s, tref3<B> const & v);
232  template <typename A, typename B>
233  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tref2<B> const & v2);
235  template <typename A, typename B>
236  GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tref2<B> const & v2);
238  template <typename A, typename B>
239  GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tvec2<B> const & v2);
240 
242  // Unary arithmetic operators
243 
244  GLM_FUNC_DECL tvec4<T> & operator= (tvec4<T> const & v);
245  template <typename U>
246  GLM_FUNC_DECL tvec4<T> & operator= (tvec4<U> const & v);
247 
248  template <typename U>
249  GLM_FUNC_DECL tvec4<T> & operator+=(U const & s);
250  template <typename U>
251  GLM_FUNC_DECL tvec4<T> & operator+=(tvec4<U> const & v);
252  template <typename U>
253  GLM_FUNC_DECL tvec4<T> & operator-=(U const & s);
254  template <typename U>
255  GLM_FUNC_DECL tvec4<T> & operator-=(tvec4<U> const & v);
256  template <typename U>
257  GLM_FUNC_DECL tvec4<T> & operator*=(U const & s);
258  template <typename U>
259  GLM_FUNC_DECL tvec4<T> & operator*=(tvec4<U> const & v);
260  template <typename U>
261  GLM_FUNC_DECL tvec4<T> & operator/=(U const & s);
262  template <typename U>
263  GLM_FUNC_DECL tvec4<T> & operator/=(tvec4<U> const & v);
264  GLM_FUNC_DECL tvec4<T> & operator++();
265  GLM_FUNC_DECL tvec4<T> & operator--();
266 
268  // Unary bit operators
269 
270  template <typename U>
271  GLM_FUNC_DECL tvec4<T> & operator%= (U const & s);
272  template <typename U>
273  GLM_FUNC_DECL tvec4<T> & operator%= (tvec4<U> const & v);
274  template <typename U>
275  GLM_FUNC_DECL tvec4<T> & operator&= (U const & s);
276  template <typename U>
277  GLM_FUNC_DECL tvec4<T> & operator&= (tvec4<U> const & v);
278  template <typename U>
279  GLM_FUNC_DECL tvec4<T> & operator|= (U const & s);
280  template <typename U>
281  GLM_FUNC_DECL tvec4<T> & operator|= (tvec4<U> const & v);
282  template <typename U>
283  GLM_FUNC_DECL tvec4<T> & operator^= (U const & s);
284  template <typename U>
285  GLM_FUNC_DECL tvec4<T> & operator^= (tvec4<U> const & v);
286  template <typename U>
287  GLM_FUNC_DECL tvec4<T> & operator<<=(U const & s);
288  template <typename U>
289  GLM_FUNC_DECL tvec4<T> & operator<<=(tvec4<U> const & v);
290  template <typename U>
291  GLM_FUNC_DECL tvec4<T> & operator>>=(U const & s);
292  template <typename U>
293  GLM_FUNC_DECL tvec4<T> & operator>>=(tvec4<U> const & v);
294 
296  // Swizzle operators
297 
298  GLM_FUNC_DECL value_type swizzle(comp X) const;
299  GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
300  GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
301  GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
302  GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
303  GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
304  GLM_FUNC_DECL tref4<T> swizzle(comp X, comp Y, comp Z, comp W);
305  };
306 
307  template <typename T>
308  struct tref4
309  {
310  GLM_FUNC_DECL tref4(T & x, T & y, T & z, T & w);
311  GLM_FUNC_DECL tref4(tref4<T> const & r);
312  GLM_FUNC_DECL explicit tref4(tvec4<T> const & v);
313 
314  GLM_FUNC_DECL tref4<T> & operator= (tref4<T> const & r);
315  GLM_FUNC_DECL tref4<T> & operator= (tvec4<T> const & v);
316 
317  GLM_FUNC_DECL tvec4<T> operator() ();
318 
319  T & x;
320  T & y;
321  T & z;
322  T & w;
323  };
324 
325  GLM_DETAIL_IS_VECTOR(tvec4);
326 }//namespace detail
327 
330 
337 
344 
351 
358 
365 
372 
379 
386 
393 
395 }//namespace glm
396 
397 #ifndef GLM_EXTERNAL_TEMPLATE
398 #include "type_vec4.inl"
399 #endif//GLM_EXTERNAL_TEMPLATE
400 
401 #endif//glm_core_type_gentype4
detail::tvec4< lowp_float > lowp_vec4
4 components vector of low precision floating-point numbers.
Definition: type_vec4.hpp:350
OpenGL Mathematics (glm.g-truc.net)
detail::tvec4< highp_float > highp_vec4
4 components vector of high precision floating-point numbers.
Definition: type_vec4.hpp:336
Definition: _swizzle.hpp:204
Definition: _detail.hpp:38
detail::tvec4< lowp_uint > lowp_uvec4
4 components vector of low precision unsigned integer numbers.
Definition: type_vec4.hpp:392
Definition: type_mat2x2.hpp:38
detail::tvec4< lowp_int > lowp_ivec4
4 components vector of low precision signed integer numbers.
Definition: type_vec4.hpp:371
detail::tvec4< mediump_uint > mediump_uvec4
4 components vector of medium precision unsigned integer numbers.
Definition: type_vec4.hpp:385
detail::tvec4< mediump_int > mediump_ivec4
4 components vector of medium precision signed integer numbers.
Definition: type_vec4.hpp:364
OpenGL Mathematics (glm.g-truc.net)
detail::tvec4< highp_int > highp_ivec4
4 components vector of high precision signed integer numbers.
Definition: type_vec4.hpp:357
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
Definition: type_mat2x2.hpp:40
detail::tvec4< mediump_float > mediump_vec4
4 components vector of medium precision floating-point numbers.
Definition: type_vec4.hpp:343
detail::tvec4< highp_uint > highp_uvec4
4 components vector of high precision unsigned integer numbers.
Definition: type_vec4.hpp:378