0.9.6: type_vec1.hpp Source File

| 0.9.6

- Main Page
- Modules
- Files

- File List

type_vec1.hpp
Go to the documentation of this file.
1
33 #pragma once
34
35 #include "../fwd.hpp"
36 #include "type_vec.hpp"
37 #ifdef GLM_SWIZZLE
38 # if GLM_HAS_ANONYMOUS_UNION
39 # include "_swizzle.hpp"
40 # else
41 # include "_swizzle_func.hpp"
42 # endif
43 #endif //GLM_SWIZZLE
44 #include <cstddef>
45
46 namespace glm
47 {
48 template <typename T, precision P = defaultp>
49 struct tvec1
50 {
52 // Implementation detail
53
54 typedef tvec1<T, P> type;
55 typedef tvec1<bool, P> bool_type;
56 typedef T value_type;
57
59 // Data
60
61 # if GLM_HAS_ANONYMOUS_UNION
62 union
63 {
64 T x;
65 T r;
66 T s;
67 /*
68 # ifdef GLM_SWIZZLE
69 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, x)
70 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, r)
71 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, s)
72 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, x)
73 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, r)
74 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, s)
75 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, x)
76 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, r)
77 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
78 # endif//GLM_SWIZZLE*/
79 };
80 # else
81 union {T x, r, s;};
82 /*
83 # ifdef GLM_SWIZZLE
84 GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4)
85 # endif//GLM_SWIZZLE*/
86 # endif
87
89 // Accesses
90
91 # ifdef GLM_FORCE_SIZE_FUNC
92 typedef size_t size_type;
94 GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
95
96 GLM_FUNC_DECL T & operator[](size_type i);
97 GLM_FUNC_DECL T const & operator[](size_type i) const;
98 # else
99 typedef length_t length_type;
101 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
102
103 GLM_FUNC_DECL T & operator[](length_type i);
104 GLM_FUNC_DECL T const & operator[](length_type i) const;
105 # endif//GLM_FORCE_SIZE_FUNC
106
108 // Implicit basic constructors
109
110 GLM_FUNC_DECL tvec1();
111 template <precision Q>
112 GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
113
115 // Explicit basic constructors
116
117 GLM_FUNC_DECL explicit tvec1(ctor);
118 GLM_FUNC_DECL explicit tvec1(T const & s);
119
121 // Conversion vector constructors
122
124 template <typename U, precision Q>
125 GLM_FUNC_DECL explicit tvec1(tvec2<U, Q> const & v);
127 template <typename U, precision Q>
128 GLM_FUNC_DECL explicit tvec1(tvec3<U, Q> const & v);
130 template <typename U, precision Q>
131 GLM_FUNC_DECL explicit tvec1(tvec4<U, Q> const & v);
132
133 # ifdef GLM_FORCE_EXPLICIT_CTOR
134 template <typename U, precision Q>
136 GLM_FUNC_DECL explicit tvec1(tvec1<U, Q> const & v);
137 # else
138 template <typename U, precision Q>
140 GLM_FUNC_DECL tvec1(tvec1<U, Q> const & v);
141 # endif
142
144 // Swizzle constructors
145
146 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
147 template <int E0>
148 GLM_FUNC_DECL tvec1(detail::_swizzle<1, T, P, tvec1<T, P>, E0, -1,-2,-3> const & that)
149 {
150 *this = that();
151 }
152 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
153
155 // Unary arithmetic operators
156
157 template <typename U>
158 GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v);
159 template <typename U>
160 GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
161 template <typename U>
162 GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
163 template <typename U>
164 GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
165 template <typename U>
166 GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
167 template <typename U>
168 GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
169 template <typename U>
170 GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
171 template <typename U>
172 GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
173 template <typename U>
174 GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
175
177 // Increment and decrement operators
178
179 GLM_FUNC_DECL tvec1<T, P> & operator++();
180 GLM_FUNC_DECL tvec1<T, P> & operator--();
181 GLM_FUNC_DECL tvec1<T, P> operator++(int);
182 GLM_FUNC_DECL tvec1<T, P> operator--(int);
183
185 // Unary bit operators
186
187 template <typename U>
188 GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
189 template <typename U>
190 GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
191 template <typename U>
192 GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
193 template <typename U>
194 GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
195 template <typename U>
196 GLM_FUNC_DECL tvec1<T, P> & operator|=(U const & s);
197 template <typename U>
198 GLM_FUNC_DECL tvec1<T, P> & operator|=(tvec1<U, P> const & v);
199 template <typename U>
200 GLM_FUNC_DECL tvec1<T, P> & operator^=(U const & s);
201 template <typename U>
202 GLM_FUNC_DECL tvec1<T, P> & operator^=(tvec1<U, P> const & v);
203 template <typename U>
204 GLM_FUNC_DECL tvec1<T, P> & operator<<=(U const & s);
205 template <typename U>
206 GLM_FUNC_DECL tvec1<T, P> & operator<<=(tvec1<U, P> const & v);
207 template <typename U>
208 GLM_FUNC_DECL tvec1<T, P> & operator>>=(U const & s);
209 template <typename U>
210 GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
211 };
212
213
214 template <typename T, precision P>
215 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
216
217 template <typename T, precision P>
218 GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
219
220 template <typename T, precision P>
221 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
222
223 template <typename T, precision P>
224 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
225
226 template <typename T, precision P>
227 GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
228
229 template <typename T, precision P>
230 GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
231
232 template <typename T, precision P>
233 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
234
235 template <typename T, precision P>
236 GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
237
238 template <typename T, precision P>
239 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
240
241 template <typename T, precision P>
242 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
243
244 template <typename T, precision P>
245 GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
246
247 template <typename T, precision P>
248 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
249
250 template <typename T, precision P>
251 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
252
253 template <typename T, precision P>
254 GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
255
256 template <typename T, precision P>
257 GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
258
259 template <typename T, precision P>
260 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
261
262 template <typename T, precision P>
263 GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
264
265 template <typename T, precision P>
266 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
267
268 template <typename T, precision P>
269 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
270
271 template <typename T, precision P>
272 GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
273
274 template <typename T, precision P>
275 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
276
277 template <typename T, precision P>
278 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
279
280 template <typename T, precision P>
281 GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
282
283 template <typename T, precision P>
284 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
285
286 template <typename T, precision P>
287 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
288
289 template <typename T, precision P>
290 GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
291
292 template <typename T, precision P>
293 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
294
295 template <typename T, precision P>
296 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
297
298 template <typename T, precision P>
299 GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
300
301 template <typename T, precision P>
302 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
303
304 template <typename T, precision P>
305 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
306
307 template <typename T, precision P>
308 GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
309
310 template <typename T, precision P>
311 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
312
313 template <typename T, precision P>
314 GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
315 }//namespace glm
316
317 #ifndef GLM_EXTERNAL_TEMPLATE
318 #include "type_vec1.inl"
319 #endif//GLM_EXTERNAL_TEMPLATE
_swizzle_func.hpp
OpenGL Mathematics (glm.g-truc.net)
glm::length
GLM_FUNC_DECL T length(vecType< T, P > const &x)
Returns the length of x, i.e., sqrt(x * x).
glm
Definition: _noise.hpp:39
type_vec.hpp
OpenGL Mathematics (glm.g-truc.net)
_swizzle.hpp
OpenGL Mathematics (glm.g-truc.net)