GLM 0.9.5

- Main Page
- Related Pages
- Modules
- Namespaces
- Files

- File List

type_vec3.hpp
1
29 #ifndef glm_core_type_gentype3
30 #define glm_core_type_gentype3
31
32 //#include "../fwd.hpp"
33 #include "type_vec.hpp"
34 #ifdef GLM_SWIZZLE
35 # if GLM_HAS_ANONYMOUS_UNION
36 # include "_swizzle.hpp"
37 # else
38 # include "_swizzle_func.hpp"
39 # endif
40 #endif //GLM_SWIZZLE
41 #if(GLM_HAS_INITIALIZER_LISTS)
42 # include <initializer_list>
43 #endif //GLM_HAS_INITIALIZER_LISTS
44 #include <cstddef>
45
46 namespace glm{
47 namespace detail
48 {
49 template <typename T, precision P>
50 struct tvec3
51 {
53 // Implementation detail
54
55 enum ctor{_null};
56
57 typedef tvec3<T, P> type;
58 typedef tvec3<bool, P> bool_type;
59 typedef T value_type;
60 typedef int size_type;
61
63 // Helper
64
65 GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
66
68 // Data
69
70 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
71 union
72 {
73 struct{ T x, y, z; };
74 struct{ T r, g, b; };
75 struct{ T s, t, p; };
76
77 _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, x, y, z)
78 _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b)
79 _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p)
80 _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, x, y, z)
81 _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, r, g, b)
82 _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, s, t, p)
83 _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, x, y, z)
84 _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b)
85 _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p)
86 };
87 # else
88 union { T x, r, s; };
89 union { T y, g, t; };
90 union { T z, b, p; };
91
92 # ifdef GLM_SWIZZLE
93 GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
94 # endif
95 # endif//GLM_LANG
96
98 // Accesses
99
100 GLM_FUNC_DECL T & operator[](length_t i);
101 GLM_FUNC_DECL T const & operator[](length_t i) const;
102
104 // Implicit basic constructors
105
106 GLM_FUNC_DECL tvec3();
107 GLM_FUNC_DECL tvec3(tvec3<T, P> const & v);
108 template <precision Q>
109 GLM_FUNC_DECL tvec3(tvec3<T, Q> const & v);
110
111 #if(GLM_HAS_INITIALIZER_LISTS)
112 template <typename U>
113 GLM_FUNC_DECL tvec3(std::initializer_list<U> const & v);
114 #endif//GLM_HAS_INITIALIZER_LISTS
115
117 // Explicit basic constructors
118
119 GLM_FUNC_DECL explicit tvec3(
120 ctor);
121 GLM_FUNC_DECL explicit tvec3(
122 T const & s);
123 GLM_FUNC_DECL explicit tvec3(
124 T const & s1,
125 T const & s2,
126 T const & s3);
127
129 // Conversion scalar constructors
130
132 template <typename U>
133 GLM_FUNC_DECL explicit tvec3(
134 U const & x);
136 template <typename U, typename V, typename W>
137 GLM_FUNC_DECL explicit tvec3(
138 U const & x,
139 V const & y,
140 W const & z);
141
143 // Conversion vector constructors
144
146 template <typename A, typename B, precision Q>
147 GLM_FUNC_DECL explicit tvec3(tvec2<A, Q> const & v, B const & s);
149 template <typename A, typename B, precision Q>
150 GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B, Q> const & v);
152 template <typename U, precision Q>
153 GLM_FUNC_DECL explicit tvec3(tvec3<U, Q> const & v);
155 template <typename U, precision Q>
156 GLM_FUNC_DECL explicit tvec3(tvec4<U, Q> const & v);
157
159 // Swizzle constructors
160
161 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
162 template <int E0, int E1, int E2>
163 GLM_FUNC_DECL tvec3(_swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & that)
164 {
165 *this = that();
166 }
167
168 template <int E0, int E1>
169 GLM_FUNC_DECL tvec3(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & s)
170 {
171 *this = tvec3<T, P>(v(), s);
172 }
173
174 template <int E0, int E1>
175 GLM_FUNC_DECL tvec3(T const & s, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
176 {
177 *this = tvec3<T, P>(s, v());
178 }
179 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
180
182 // Unary arithmetic operators
183
184 GLM_FUNC_DECL tvec3<T, P> & operator= (tvec3<T, P> const & v);
185 template <typename U>
186 GLM_FUNC_DECL tvec3<T, P> & operator= (tvec3<U, P> const & v);
187
188 template <typename U>
189 GLM_FUNC_DECL tvec3<T, P> & operator+=(U s);
190 template <typename U>
191 GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec3<U, P> const & v);
192 template <typename U>
193 GLM_FUNC_DECL tvec3<T, P> & operator-=(U s);
194 template <typename U>
195 GLM_FUNC_DECL tvec3<T, P> & operator-=(tvec3<U, P> const & v);
196 template <typename U>
197 GLM_FUNC_DECL tvec3<T, P> & operator*=(U s);
198 template <typename U>
199 GLM_FUNC_DECL tvec3<T, P> & operator*=(tvec3<U, P> const & v);
200 template <typename U>
201 GLM_FUNC_DECL tvec3<T, P> & operator/=(U s);
202 template <typename U>
203 GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec3<U, P> const & v);
204
206 // Increment and decrement operators
207
208 GLM_FUNC_DECL tvec3<T, P> & operator++();
209 GLM_FUNC_DECL tvec3<T, P> & operator--();
210 GLM_FUNC_DECL tvec3<T, P> operator++(int);
211 GLM_FUNC_DECL tvec3<T, P> operator--(int);
212
214 // Unary bit operators
215
216 template <typename U>
217 GLM_FUNC_DECL tvec3<T, P> & operator%= (U s);
218 template <typename U>
219 GLM_FUNC_DECL tvec3<T, P> & operator%= (tvec3<U, P> const & v);
220 template <typename U>
221 GLM_FUNC_DECL tvec3<T, P> & operator&= (U s);
222 template <typename U>
223 GLM_FUNC_DECL tvec3<T, P> & operator&= (tvec3<U, P> const & v);
224 template <typename U>
225 GLM_FUNC_DECL tvec3<T, P> & operator|= (U s);
226 template <typename U>
227 GLM_FUNC_DECL tvec3<T, P> & operator|= (tvec3<U, P> const & v);
228 template <typename U>
229 GLM_FUNC_DECL tvec3<T, P> & operator^= (U s);
230 template <typename U>
231 GLM_FUNC_DECL tvec3<T, P> & operator^= (tvec3<U, P> const & v);
232 template <typename U>
233 GLM_FUNC_DECL tvec3<T, P> & operator<<=(U s);
234 template <typename U>
235 GLM_FUNC_DECL tvec3<T, P> & operator<<=(tvec3<U, P> const & v);
236 template <typename U>
237 GLM_FUNC_DECL tvec3<T, P> & operator>>=(U s);
238 template <typename U>
239 GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec3<U, P> const & v);
240 };
241
242 GLM_DETAIL_IS_VECTOR(tvec3);
243
244 template <typename T, precision P>
245 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T const & s);
246
247 template <typename T, precision P>
248 GLM_FUNC_DECL tvec3<T, P> operator+(T const & s, tvec3<T, P> const & v);
249
250 template <typename T, precision P>
251 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
252
253 template <typename T, precision P>
254 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, T const & s);
255
256 template <typename T, precision P>
257 GLM_FUNC_DECL tvec3<T, P> operator-(T const & s, tvec3<T, P> const & v);
258
259 template <typename T, precision P>
260 GLM_FUNC_DECL tvec3<T, P> operator- (tvec3<T, P> const & v1, tvec3<T, P> const & v2);
261
262 template <typename T, precision P>
263 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, T const & s);
264
265 template <typename T, precision P>
266 GLM_FUNC_DECL tvec3<T, P> operator*(T const & s, tvec3<T, P> const & v);
267
268 template <typename T, precision P>
269 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
270
271 template <typename T, precision P>
272 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, T const & s);
273
274 template <typename T, precision P>
275 GLM_FUNC_DECL tvec3<T, P> operator/(T const & s, tvec3<T, P> const & v);
276
277 template <typename T, precision P>
278 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
279
280 template <typename T, precision P>
281 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
282
283 template <typename T, precision P>
284 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, T const & s);
285
286 template <typename T, precision P>
287 GLM_FUNC_DECL tvec3<T, P> operator%(T const & s, tvec3<T, P> const & v);
288
289 template <typename T, precision P>
290 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
291
292 template <typename T, precision P>
293 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, T const & s);
294
295 template <typename T, precision P>
296 GLM_FUNC_DECL tvec3<T, P> operator&(T const & s, tvec3<T, P> const & v);
297
298 template <typename T, precision P>
299 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
300
301 template <typename T, precision P>
302 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, T const & s);
303
304 template <typename T, precision P>
305 GLM_FUNC_DECL tvec3<T, P> operator|(T const & s, tvec3<T, P> const & v);
306
307 template <typename T, precision P>
308 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
309
310 template <typename T, precision P>
311 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, T const & s);
312
313 template <typename T, precision P>
314 GLM_FUNC_DECL tvec3<T, P> operator^(T const & s, tvec3<T, P> const & v);
315
316 template <typename T, precision P>
317 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
318
319 template <typename T, precision P>
320 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & s);
321
322 template <typename T, precision P>
323 GLM_FUNC_DECL tvec3<T, P> operator<<(T const & s, tvec3<T, P> const & v);
324
325 template <typename T, precision P>
326 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
327
328 template <typename T, precision P>
329 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & s);
330
331 template <typename T, precision P>
332 GLM_FUNC_DECL tvec3<T, P> operator>>(T const & s, tvec3<T, P> const & v);
333
334 template <typename T, precision P>
335 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
336
337 template <typename T, precision P>
338 GLM_FUNC_DECL tvec3<T, P> operator~(tvec3<T, P> const & v);
339
340 }//namespace detail
341 }//namespace glm
342
343 #ifndef GLM_EXTERNAL_TEMPLATE
344 #include "type_vec3.inl"
345 #endif//GLM_EXTERNAL_TEMPLATE
346
347 #endif//glm_core_type_gentype3
glm::length
GLM_FUNC_DECL genType::value_type length(genType const &x)
Returns the length of x, i.e., sqrt(x * x).