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, typename V, typename W>
133 GLM_FUNC_DECL explicit tvec3(
134 U const & x,
135 V const & y,
136 W const & z);
137
139 // Conversion vector constructors
140
142 template <typename A, typename B, precision Q>
143 GLM_FUNC_DECL explicit tvec3(tvec2<A, Q> const & v, B const & s);
145 template <typename A, typename B, precision Q>
146 GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B, Q> const & v);
148 template <typename U, precision Q>
149 GLM_FUNC_DECL explicit tvec3(tvec3<U, Q> const & v);
151 template <typename U, precision Q>
152 GLM_FUNC_DECL explicit tvec3(tvec4<U, Q> const & v);
153
155 // Swizzle constructors
156
157 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
158 template <int E0, int E1, int E2>
159 GLM_FUNC_DECL tvec3(_swizzle<3, T, P, tvec3<T, P>, E0, E1, E2, -1> const & that)
160 {
161 *this = that();
162 }
163
164 template <int E0, int E1>
165 GLM_FUNC_DECL tvec3(_swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v, T const & s)
166 {
167 *this = tvec3<T, P>(v(), s);
168 }
169
170 template <int E0, int E1>
171 GLM_FUNC_DECL tvec3(T const & s, _swizzle<2, T, P, tvec2<T, P>, E0, E1, -1, -2> const & v)
172 {
173 *this = tvec3<T, P>(s, v());
174 }
175 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
176
178 // Unary arithmetic operators
179
180 GLM_FUNC_DECL tvec3<T, P> & operator= (tvec3<T, P> const & v);
181 template <typename U>
182 GLM_FUNC_DECL tvec3<T, P> & operator= (tvec3<U, P> const & v);
183
184 template <typename U>
185 GLM_FUNC_DECL tvec3<T, P> & operator+=(U s);
186 template <typename U>
187 GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec3<U, P> const & v);
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
202 // Increment and decrement operators
203
204 GLM_FUNC_DECL tvec3<T, P> & operator++();
205 GLM_FUNC_DECL tvec3<T, P> & operator--();
206 GLM_FUNC_DECL tvec3<T, P> operator++(int);
207 GLM_FUNC_DECL tvec3<T, P> operator--(int);
208
210 // Unary bit operators
211
212 template <typename U>
213 GLM_FUNC_DECL tvec3<T, P> & operator%= (U s);
214 template <typename U>
215 GLM_FUNC_DECL tvec3<T, P> & operator%= (tvec3<U, P> const & v);
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 };
237
238 template <typename T, precision P>
239 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T const & s);
240
241 template <typename T, precision P>
242 GLM_FUNC_DECL tvec3<T, P> operator+(T const & s, tvec3<T, P> const & v);
243
244 template <typename T, precision P>
245 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
246
247 template <typename T, precision P>
248 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, T const & s);
249
250 template <typename T, precision P>
251 GLM_FUNC_DECL tvec3<T, P> operator-(T const & s, tvec3<T, P> const & v);
252
253 template <typename T, precision P>
254 GLM_FUNC_DECL tvec3<T, P> operator- (tvec3<T, P> const & v1, tvec3<T, P> const & v2);
255
256 template <typename T, precision P>
257 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, T const & s);
258
259 template <typename T, precision P>
260 GLM_FUNC_DECL tvec3<T, P> operator*(T const & s, tvec3<T, P> const & v);
261
262 template <typename T, precision P>
263 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
264
265 template <typename T, precision P>
266 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, T const & s);
267
268 template <typename T, precision P>
269 GLM_FUNC_DECL tvec3<T, P> operator/(T const & s, tvec3<T, P> const & v);
270
271 template <typename T, precision P>
272 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
273
274 template <typename T, precision P>
275 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
276
277 template <typename T, precision P>
278 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, T const & s);
279
280 template <typename T, precision P>
281 GLM_FUNC_DECL tvec3<T, P> operator%(T const & s, tvec3<T, P> const & v);
282
283 template <typename T, precision P>
284 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
285
286 template <typename T, precision P>
287 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v, T const & s);
288
289 template <typename T, precision P>
290 GLM_FUNC_DECL tvec3<T, P> operator&(T const & s, tvec3<T, P> const & v);
291
292 template <typename T, precision P>
293 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
294
295 template <typename T, precision P>
296 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, T const & s);
297
298 template <typename T, precision P>
299 GLM_FUNC_DECL tvec3<T, P> operator|(T const & s, tvec3<T, P> const & v);
300
301 template <typename T, precision P>
302 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
303
304 template <typename T, precision P>
305 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, T const & s);
306
307 template <typename T, precision P>
308 GLM_FUNC_DECL tvec3<T, P> operator^(T const & s, tvec3<T, P> const & v);
309
310 template <typename T, precision P>
311 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
312
313 template <typename T, precision P>
314 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, T const & s);
315
316 template <typename T, precision P>
317 GLM_FUNC_DECL tvec3<T, P> operator<<(T const & s, tvec3<T, P> const & v);
318
319 template <typename T, precision P>
320 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
321
322 template <typename T, precision P>
323 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, T const & s);
324
325 template <typename T, precision P>
326 GLM_FUNC_DECL tvec3<T, P> operator>>(T const & s, tvec3<T, P> const & v);
327
328 template <typename T, precision P>
329 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
330
331 template <typename T, precision P>
332 GLM_FUNC_DECL tvec3<T, P> operator~(tvec3<T, P> const & v);
333
334 }//namespace detail
335 }//namespace glm
336
337 #ifndef GLM_EXTERNAL_TEMPLATE
338 #include "type_vec3.inl"
339 #endif//GLM_EXTERNAL_TEMPLATE
340
341 #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).