0.9.7: type_vec1.hpp Source File

| 0.9.7

- 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 {
51 // -- Implementation detail --
52
53 typedef tvec1<T, P> type;
54 typedef tvec1<bool, P> bool_type;
55 typedef T value_type;
56
57 # ifdef GLM_META_PROG_HELPERS
58 static GLM_RELAXED_CONSTEXPR length_t components = 1;
59 static GLM_RELAXED_CONSTEXPR precision prec = P;
60 # endif//GLM_META_PROG_HELPERS
61
62 // -- Data --
63
64 # if GLM_HAS_ANONYMOUS_UNION
65 union
66 {
67 T x;
68 T r;
69 T s;
70 /*
71 # ifdef GLM_SWIZZLE
72 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, x)
73 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, r)
74 _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, s)
75 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, x)
76 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, r)
77 _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, s)
78 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, x)
79 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, r)
80 _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
81 # endif//GLM_SWIZZLE*/
82 };
83 # else
84 union {T x, r, s;};
85 /*
86 # ifdef GLM_SWIZZLE
87 GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4)
88 # endif//GLM_SWIZZLE*/
89 # endif
90
91 // -- Component accesses --
92
93 # ifdef GLM_FORCE_SIZE_FUNC
94 typedef size_t size_type;
96 GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
97
98 GLM_FUNC_DECL T & operator[](size_type i);
99 GLM_FUNC_DECL T const & operator[](size_type i) const;
100 # else
101 typedef length_t length_type;
103 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
104
105 GLM_FUNC_DECL T & operator[](length_type i);
106 GLM_FUNC_DECL T const & operator[](length_type i) const;
107 # endif//GLM_FORCE_SIZE_FUNC
108
109 // -- Implicit basic constructors --
110
111 GLM_FUNC_DECL tvec1() GLM_DEFAULT_CTOR;
112 GLM_FUNC_DECL tvec1(tvec1<T, P> const & v) GLM_DEFAULT;
113 template <precision Q>
114 GLM_FUNC_DECL tvec1(tvec1<T, Q> const & v);
115
116 // -- Explicit basic constructors --
117
118 GLM_FUNC_DECL explicit tvec1(ctor);
119 GLM_FUNC_DECL explicit tvec1(T const & s);
120
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
134 template <typename U, precision Q>
135 GLM_FUNC_DECL GLM_EXPLICIT tvec1(tvec1<U, Q> const & v);
136
137 // -- Swizzle constructors --
138
139 # if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
140 template <int E0>
141 GLM_FUNC_DECL tvec1(detail::_swizzle<1, T, P, tvec1<T, P>, E0, -1,-2,-3> const & that)
142 {
143 *this = that();
144 }
145 # endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
146
147 // -- Unary arithmetic operators --
148
149 GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<T, P> const & v) GLM_DEFAULT;
150
151 template <typename U>
152 GLM_FUNC_DECL tvec1<T, P> & operator=(tvec1<U, P> const & v);
153 template <typename U>
154 GLM_FUNC_DECL tvec1<T, P> & operator+=(U const & s);
155 template <typename U>
156 GLM_FUNC_DECL tvec1<T, P> & operator+=(tvec1<U, P> const & v);
157 template <typename U>
158 GLM_FUNC_DECL tvec1<T, P> & operator-=(U const & s);
159 template <typename U>
160 GLM_FUNC_DECL tvec1<T, P> & operator-=(tvec1<U, P> const & v);
161 template <typename U>
162 GLM_FUNC_DECL tvec1<T, P> & operator*=(U const & s);
163 template <typename U>
164 GLM_FUNC_DECL tvec1<T, P> & operator*=(tvec1<U, P> const & v);
165 template <typename U>
166 GLM_FUNC_DECL tvec1<T, P> & operator/=(U const & s);
167 template <typename U>
168 GLM_FUNC_DECL tvec1<T, P> & operator/=(tvec1<U, P> const & v);
169
170 // -- Increment and decrement operators --
171
172 GLM_FUNC_DECL tvec1<T, P> & operator++();
173 GLM_FUNC_DECL tvec1<T, P> & operator--();
174 GLM_FUNC_DECL tvec1<T, P> operator++(int);
175 GLM_FUNC_DECL tvec1<T, P> operator--(int);
176
177 // -- Unary bit operators --
178
179 template <typename U>
180 GLM_FUNC_DECL tvec1<T, P> & operator%=(U const & s);
181 template <typename U>
182 GLM_FUNC_DECL tvec1<T, P> & operator%=(tvec1<U, P> const & v);
183 template <typename U>
184 GLM_FUNC_DECL tvec1<T, P> & operator&=(U const & s);
185 template <typename U>
186 GLM_FUNC_DECL tvec1<T, P> & operator&=(tvec1<U, P> const & v);
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 };
204
205 // -- Unary operators --
206
207 template <typename T, precision P>
208 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
209
210 // -- Binary operators --
211
212 template <typename T, precision P>
213 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
214
215 template <typename T, precision P>
216 GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
217
218 template <typename T, precision P>
219 GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
220
221 template <typename T, precision P>
222 GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
223
224 template <typename T, precision P>
225 GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
226
227 template <typename T, precision P>
228 GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
229
230 template <typename T, precision P>
231 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
232
233 template <typename T, precision P>
234 GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
235
236 template <typename T, precision P>
237 GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
238
239 template <typename T, precision P>
240 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
241
242 template <typename T, precision P>
243 GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
244
245 template <typename T, precision P>
246 GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
247
248 template <typename T, precision P>
249 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
250
251 template <typename T, precision P>
252 GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
253
254 template <typename T, precision P>
255 GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
256
257 template <typename T, precision P>
258 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
259
260 template <typename T, precision P>
261 GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
262
263 template <typename T, precision P>
264 GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
265
266 template <typename T, precision P>
267 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
268
269 template <typename T, precision P>
270 GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
271
272 template <typename T, precision P>
273 GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
274
275 template <typename T, precision P>
276 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
277
278 template <typename T, precision P>
279 GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
280
281 template <typename T, precision P>
282 GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
283
284 template <typename T, precision P>
285 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
286
287 template <typename T, precision P>
288 GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
289
290 template <typename T, precision P>
291 GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
292
293 template <typename T, precision P>
294 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
295
296 template <typename T, precision P>
297 GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
298
299 template <typename T, precision P>
300 GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
301
302 template <typename T, precision P>
303 GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
304
305 // -- Boolean operators --
306
307 template <typename T, precision P>
308 GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
309
310 template <typename T, precision P>
311 GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
312 }//namespace glm
313
314 #ifndef GLM_EXTERNAL_TEMPLATE
315 #include "type_vec1.inl"
316 #endif//GLM_EXTERNAL_TEMPLATE
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:40
_swizzle_func.hpp
OpenGL Mathematics (glm.g-truc.net)
type_vec.hpp
OpenGL Mathematics (glm.g-truc.net)
_swizzle.hpp
OpenGL Mathematics (glm.g-truc.net)