PSMoveService
type_vec2.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype2
30 #define glm_core_type_gentype2
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 tvec3;
45  template <typename T> struct tvec4;
46 
47  // The basic 2D vector type.
48  // \ingroup core_template
49  template <typename T>
50  struct tvec2
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 tvec2<T> type;
59  typedef tvec2<bool> bool_type;
60 
62  // Data
63 
64 # if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
65  union
66  {
67 # if(defined(GLM_SWIZZLE))
68  _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y)
69  _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g)
70  _GLM_SWIZZLE2_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t)
71  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y)
72  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g)
73  _GLM_SWIZZLE2_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t)
74  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y)
75  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g)
76  _GLM_SWIZZLE2_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t)
77 # endif//(defined(GLM_SWIZZLE))
78 
79  struct{value_type r, g;};
80  struct{value_type s, t;};
81  struct{value_type x, y;};
82  };
83 # elif(GLM_COMPONENT == GLM_COMPONENT_CXX98)
84  union {value_type x, r, s;};
85  union {value_type y, g, t;};
86 
87 # if(defined(GLM_SWIZZLE))
88  // Defines all he swizzle operator as functions
89  GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, detail::tvec2, detail::tref2)
90  GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
91 # endif//(defined(GLM_SWIZZLE))
92 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
93  value_type x, y;
94 
95 # if(defined(GLM_SWIZZLE))
96  // Defines all he swizzle operator as functions
97  GLM_SWIZZLE_GEN_REF2_FROM_VEC2_SWIZZLE(value_type, detail::tvec2, detail::tref2, x, y)
98  GLM_SWIZZLE_GEN_VEC_FROM_VEC2_COMP(value_type, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4, x, y)
99 # endif//(defined(GLM_SWIZZLE))
100 # endif//GLM_COMPONENT
101 
103  // Accesses
104 
105  GLM_FUNC_DECL value_type & operator[](size_type i);
106  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
107 
109  // Implicit basic constructors
110 
111  GLM_FUNC_DECL tvec2();
112  GLM_FUNC_DECL tvec2(tvec2<T> const & v);
113 
115  // Explicit basic constructors
116 
117  GLM_FUNC_DECL explicit tvec2(
118  ctor);
119  GLM_FUNC_DECL explicit tvec2(
120  value_type const & s);
121  GLM_FUNC_DECL explicit tvec2(
122  value_type const & s1,
123  value_type const & s2);
124 
126  // Swizzle constructors
127 
128  tvec2(tref2<T> const & r);
129 
130  template <int E0, int E1>
131  GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2<T>,E0,E1,-1,-2>& that)
132  {
133  *this = that();
134  }
135 
137  // Convertion constructors
138 
140  template <typename U>
141  GLM_FUNC_DECL explicit tvec2(
142  U const & x);
144  template <typename U, typename V>
145  GLM_FUNC_DECL explicit tvec2(
146  U const & x,
147  V const & y);
148 
150  // Convertion vector constructors
151 
153  template <typename U>
154  GLM_FUNC_DECL explicit tvec2(tvec2<U> const & v);
156  template <typename U>
157  GLM_FUNC_DECL explicit tvec2(tvec3<U> const & v);
159  template <typename U>
160  GLM_FUNC_DECL explicit tvec2(tvec4<U> const & v);
161 
163  // Unary arithmetic operators
164 
165  GLM_FUNC_DECL tvec2<T> & operator= (tvec2<T> const & v);
166  template <typename U>
167  GLM_FUNC_DECL tvec2<T> & operator= (tvec2<U> const & v);
168 
169  template <typename U>
170  GLM_FUNC_DECL tvec2<T> & operator+=(U const & s);
171  template <typename U>
172  GLM_FUNC_DECL tvec2<T> & operator+=(tvec2<U> const & v);
173  template <typename U>
174  GLM_FUNC_DECL tvec2<T> & operator-=(U const & s);
175  template <typename U>
176  GLM_FUNC_DECL tvec2<T> & operator-=(tvec2<U> const & v);
177  template <typename U>
178  GLM_FUNC_DECL tvec2<T> & operator*=(U const & s);
179  template <typename U>
180  GLM_FUNC_DECL tvec2<T> & operator*=(tvec2<U> const & v);
181  template <typename U>
182  GLM_FUNC_DECL tvec2<T> & operator/=(U const & s);
183  template <typename U>
184  GLM_FUNC_DECL tvec2<T> & operator/=(tvec2<U> const & v);
185  GLM_FUNC_DECL tvec2<T> & operator++();
186  GLM_FUNC_DECL tvec2<T> & operator--();
187 
189  // Unary bit operators
190 
191  template <typename U>
192  GLM_FUNC_DECL tvec2<T> & operator%= (U const & s);
193  template <typename U>
194  GLM_FUNC_DECL tvec2<T> & operator%= (tvec2<U> const & v);
195  template <typename U>
196  GLM_FUNC_DECL tvec2<T> & operator&= (U const & s);
197  template <typename U>
198  GLM_FUNC_DECL tvec2<T> & operator&= (tvec2<U> const & v);
199  template <typename U>
200  GLM_FUNC_DECL tvec2<T> & operator|= (U const & s);
201  template <typename U>
202  GLM_FUNC_DECL tvec2<T> & operator|= (tvec2<U> const & v);
203  template <typename U>
204  GLM_FUNC_DECL tvec2<T> & operator^= (U const & s);
205  template <typename U>
206  GLM_FUNC_DECL tvec2<T> & operator^= (tvec2<U> const & v);
207  template <typename U>
208  GLM_FUNC_DECL tvec2<T> & operator<<=(U const & s);
209  template <typename U>
210  GLM_FUNC_DECL tvec2<T> & operator<<=(tvec2<U> const & v);
211  template <typename U>
212  GLM_FUNC_DECL tvec2<T> & operator>>=(U const & s);
213  template <typename U>
214  GLM_FUNC_DECL tvec2<T> & operator>>=(tvec2<U> const & v);
215 
217  // Swizzle operators
218 
219  GLM_FUNC_DECL value_type swizzle(comp X) const;
220  GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
221  GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
222  GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
223  GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
224  };
225 
226  template <typename T>
227  struct tref2
228  {
229  GLM_FUNC_DECL tref2(T & x, T & y);
230  GLM_FUNC_DECL tref2(tref2<T> const & r);
231  GLM_FUNC_DECL explicit tref2(tvec2<T> const & v);
232 
233  GLM_FUNC_DECL tref2<T> & operator= (tref2<T> const & r);
234  GLM_FUNC_DECL tref2<T> & operator= (tvec2<T> const & v);
235 
236  GLM_FUNC_DECL tvec2<T> operator() ();
237 
238  T & x;
239  T & y;
240  };
241 
242  GLM_DETAIL_IS_VECTOR(tvec2);
243 
244 } //namespace detail
245 
248 
255 
262 
269 
276 
283 
290 
297 
304 
311 
313 }//namespace glm
314 
315 #ifndef GLM_EXTERNAL_TEMPLATE
316 #include "type_vec2.inl"
317 #endif//GLM_EXTERNAL_TEMPLATE
318 
319 #endif//glm_core_type_gentype2
OpenGL Mathematics (glm.g-truc.net)
detail::tvec2< lowp_uint > lowp_uvec2
2 components vector of low precision unsigned integer numbers.
Definition: type_vec2.hpp:310
detail::tvec2< highp_int > highp_ivec2
2 components vector of high precision signed integer numbers.
Definition: type_vec2.hpp:275
Definition: _swizzle.hpp:204
Definition: _detail.hpp:38
Definition: type_mat2x2.hpp:38
detail::tvec2< mediump_uint > mediump_uvec2
2 components vector of medium precision unsigned integer numbers.
Definition: type_vec2.hpp:303
detail::tvec2< mediump_float > mediump_vec2
2 components vector of medium precision floating-point numbers.
Definition: type_vec2.hpp:261
detail::tvec2< lowp_int > lowp_ivec2
2 components vector of low precision signed integer numbers.
Definition: type_vec2.hpp:289
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
detail::tvec2< mediump_int > mediump_ivec2
2 components vector of medium precision signed integer numbers.
Definition: type_vec2.hpp:282
detail::tvec2< lowp_float > lowp_vec2
2 components vector of low precision floating-point numbers.
Definition: type_vec2.hpp:268
detail::tvec2< highp_float > highp_vec2
2 components vector of high precision floating-point numbers.
Definition: type_vec2.hpp:254
detail::tvec2< highp_uint > highp_uvec2
2 components vector of high precision unsigned integer numbers.
Definition: type_vec2.hpp:296