PSMoveService
type_vec3.hpp
Go to the documentation of this file.
1 
29 #ifndef glm_core_type_gentype3
30 #define glm_core_type_gentype3
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 tvec4;
46 
47  // Basic 3D vector type.
48  // \ingroup core_template
49  template <typename T>
50  struct tvec3
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 tvec3<T> type;
59  typedef tvec3<bool> bool_type;
60 
62  // Data
63 
64 # if(GLM_COMPONENT == GLM_COMPONENT_CXX11)
65  union
66  {
67 # if(defined(GLM_SWIZZLE))
68  _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, x, y, z)
69  _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, r, g, b)
70  _GLM_SWIZZLE3_2_MEMBERS(value_type, glm::detail::tvec2<value_type>, s, t, p)
71  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, x, y, z)
72  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, r, g, b)
73  _GLM_SWIZZLE3_3_MEMBERS(value_type, glm::detail::tvec3<value_type>, s, t, p)
74  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, x, y, z)
75  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, r, g, b)
76  _GLM_SWIZZLE3_4_MEMBERS(value_type, glm::detail::tvec4<value_type>, s, t, p)
77 # endif//(defined(GLM_SWIZZLE))
78 
79  struct{value_type r, g, b;};
80  struct{value_type s, t, p;};
81  struct{value_type x, y, z;};
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 
88 # if(defined(GLM_SWIZZLE))
89  // Defines all he swizzle operator as functions
90  GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, detail::tvec3, detail::tref2, detail::tref3)
91  GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
92 # endif//(defined(GLM_SWIZZLE))
93 # else //(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
94  value_type x, y, z;
95 
96 # if(defined(GLM_SWIZZLE))
97  // Defines all he swizzle operator as functions
98  GLM_SWIZZLE_GEN_REF_FROM_VEC3_COMP(T, detail::tvec3, detail::tref2, detail::tref3, x, y, z)
99  GLM_SWIZZLE_GEN_VEC_FROM_VEC3_COMP(T, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4, x, y, z)
100 # endif//(defined(GLM_SWIZZLE))
101 # endif//GLM_COMPONENT
102 
104  // Accesses
105 
106  GLM_FUNC_DECL value_type & operator[](size_type i);
107  GLM_FUNC_DECL value_type const & operator[](size_type i) const;
108 
110  // Implicit basic constructors
111 
112  GLM_FUNC_DECL tvec3();
113  GLM_FUNC_DECL tvec3(tvec3<T> const & v);
114 
116  // Explicit basic constructors
117 
118  GLM_FUNC_DECL explicit tvec3(
119  ctor);
120  GLM_FUNC_DECL explicit tvec3(
121  value_type const & s);
122  GLM_FUNC_DECL explicit tvec3(
123  value_type const & s1,
124  value_type const & s2,
125  value_type const & s3);
126 
128  // Convertion scalar constructors
129 
131  template <typename U>
132  GLM_FUNC_DECL explicit tvec3(
133  U const & x);
135  template <typename U, typename V, typename W>
136  GLM_FUNC_DECL explicit tvec3(
137  U const & x,
138  V const & y,
139  W const & z);
140 
142  // Convertion vector constructors
143 
145  template <typename A, typename B>
146  GLM_FUNC_DECL explicit tvec3(tvec2<A> const & v, B const & s);
148  template <typename A, typename B>
149  GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B> const & v);
151  template <typename U>
152  GLM_FUNC_DECL explicit tvec3(tvec3<U> const & v);
154  template <typename U>
155  GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
156 
158  // Swizzle constructors
159 
160  GLM_FUNC_DECL tvec3(tref3<T> const & r);
161 
162  template <typename A, typename B>
163  GLM_FUNC_DECL explicit tvec3(tref2<A> const & v, B const & s);
164 
165  template <typename A, typename B>
166  GLM_FUNC_DECL explicit tvec3(A const & s, tref2<B> const & v);
167 
168  template <int E0, int E1, int E2>
169  GLM_FUNC_DECL tvec3(glm::detail::swizzle<3, T, tvec3<T>, E0, E1, E2, -1> const & that)
170  {
171  *this = that();
172  }
173 
174  template <int E0, int E1>
175  GLM_FUNC_DECL tvec3(glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v, T const & s)
176  {
177  *this = tvec3<T>(v(), s);
178  }
179 
180  template <int E0, int E1>
181  GLM_FUNC_DECL tvec3(T const & s, glm::detail::swizzle<2, T, tvec2<T>, E0, E1, -1, -2> const & v)
182  {
183  *this = tvec3<T>(s, v());
184  }
185 
187  // Unary arithmetic operators
188 
189  GLM_FUNC_DECL tvec3<T> & operator= (tvec3<T> const & v);
190  template <typename U>
191  GLM_FUNC_DECL tvec3<T> & operator= (tvec3<U> const & v);
192 
193  template <typename U>
194  GLM_FUNC_DECL tvec3<T> & operator+=(U const & s);
195  template <typename U>
196  GLM_FUNC_DECL tvec3<T> & operator+=(tvec3<U> const & v);
197  template <typename U>
198  GLM_FUNC_DECL tvec3<T> & operator-=(U const & s);
199  template <typename U>
200  GLM_FUNC_DECL tvec3<T> & operator-=(tvec3<U> const & v);
201  template <typename U>
202  GLM_FUNC_DECL tvec3<T> & operator*=(U const & s);
203  template <typename U>
204  GLM_FUNC_DECL tvec3<T> & operator*=(tvec3<U> const & v);
205  template <typename U>
206  GLM_FUNC_DECL tvec3<T> & operator/=(U const & s);
207  template <typename U>
208  GLM_FUNC_DECL tvec3<T> & operator/=(tvec3<U> const & v);
209  GLM_FUNC_DECL tvec3<T> & operator++();
210  GLM_FUNC_DECL tvec3<T> & operator--();
211 
213  // Unary bit operators
214 
215  template <typename U>
216  GLM_FUNC_DECL tvec3<T> & operator%= (U const & s);
217  template <typename U>
218  GLM_FUNC_DECL tvec3<T> & operator%= (tvec3<U> const & v);
219  template <typename U>
220  GLM_FUNC_DECL tvec3<T> & operator&= (U const & s);
221  template <typename U>
222  GLM_FUNC_DECL tvec3<T> & operator&= (tvec3<U> const & v);
223  template <typename U>
224  GLM_FUNC_DECL tvec3<T> & operator|= (U const & s);
225  template <typename U>
226  GLM_FUNC_DECL tvec3<T> & operator|= (tvec3<U> const & v);
227  template <typename U>
228  GLM_FUNC_DECL tvec3<T> & operator^= (U const & s);
229  template <typename U>
230  GLM_FUNC_DECL tvec3<T> & operator^= (tvec3<U> const & v);
231  template <typename U>
232  GLM_FUNC_DECL tvec3<T> & operator<<=(U const & s);
233  template <typename U>
234  GLM_FUNC_DECL tvec3<T> & operator<<=(tvec3<U> const & v);
235  template <typename U>
236  GLM_FUNC_DECL tvec3<T> & operator>>=(U const & s);
237  template <typename U>
238  GLM_FUNC_DECL tvec3<T> & operator>>=(tvec3<U> const & v);
239 
241  // Swizzle operators
242 
243  GLM_FUNC_DECL value_type swizzle(comp X) const;
244  GLM_FUNC_DECL tvec2<T> swizzle(comp X, comp Y) const;
245  GLM_FUNC_DECL tvec3<T> swizzle(comp X, comp Y, comp Z) const;
246  GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
247  GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
248  GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
249  };
250 
251  template <typename T>
252  struct tref3
253  {
254  GLM_FUNC_DECL tref3(T & x, T & y, T & z);
255  GLM_FUNC_DECL tref3(tref3<T> const & r);
256  GLM_FUNC_DECL explicit tref3(tvec3<T> const & v);
257 
258  GLM_FUNC_DECL tref3<T> & operator= (tref3<T> const & r);
259  GLM_FUNC_DECL tref3<T> & operator= (tvec3<T> const & v);
260 
261  GLM_FUNC_DECL tvec3<T> operator() ();
262 
263  T & x;
264  T & y;
265  T & z;
266  };
267 
268  GLM_DETAIL_IS_VECTOR(tvec3);
269 } //namespace detail
270 
273 
280 
287 
294 
301 
308 
315 
322 
329 
336 
338 }//namespace glm
339 
340 #ifndef GLM_EXTERNAL_TEMPLATE
341 #include "type_vec3.inl"
342 #endif//GLM_EXTERNAL_TEMPLATE
343 
344 #endif//glm_core_type_gentype3
detail::tvec3< mediump_int > mediump_ivec3
3 components vector of medium precision signed integer numbers.
Definition: type_vec3.hpp:307
OpenGL Mathematics (glm.g-truc.net)
Definition: _swizzle.hpp:204
Definition: _detail.hpp:38
Definition: type_mat2x2.hpp:38
detail::tvec3< mediump_float > mediump_vec3
3 components vector of medium precision floating-point numbers.
Definition: type_vec3.hpp:286
OpenGL Mathematics (glm.g-truc.net)
detail::tvec3< lowp_int > lowp_ivec3
3 components vector of low precision signed integer numbers.
Definition: type_vec3.hpp:314
detail::tvec3< highp_uint > highp_uvec3
3 components vector of high precision unsigned integer numbers.
Definition: type_vec3.hpp:321
detail::tvec3< highp_int > highp_ivec3
3 components vector of high precision signed integer numbers.
Definition: type_vec3.hpp:300
Definition: type_mat2x2.hpp:39
detail::tvec3< lowp_float > lowp_vec3
3 components vector of low precision floating-point numbers.
Definition: type_vec3.hpp:293
OpenGL Mathematics (glm.g-truc.net)
detail::tvec3< mediump_uint > mediump_uvec3
3 components vector of medium precision unsigned integer numbers.
Definition: type_vec3.hpp:328
OpenGL Mathematics (glm.g-truc.net)
OpenGL Mathematics (glm.g-truc.net)
detail::tvec3< lowp_uint > lowp_uvec3
3 components vector of low precision unsigned integer numbers.
Definition: type_vec3.hpp:335
detail::tvec3< highp_float > highp_vec3
3 components vector of high precision floating-point numbers.
Definition: type_vec3.hpp:279