Clutter Engine 0.0.1
Loading...
Searching...
No Matches
associated_min_max.inl
1
2
3namespace glm{
4
5// Min comparison between 2 variables
6template<typename T, typename U, qualifier Q>
7GLM_FUNC_QUALIFIER U associatedMin(T x, U a, T y, U b)
8{
9 return x < y ? a : b;
10}
11
12template<length_t L, typename T, typename U, qualifier Q>
13GLM_FUNC_QUALIFIER vec<2, U, Q> associatedMin
14(
15 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
16 vec<L, T, Q> const& y, vec<L, U, Q> const& b
17)
18{
19 vec<L, U, Q> Result;
20 for(length_t i = 0, n = Result.length(); i < n; ++i)
21 Result[i] = x[i] < y[i] ? a[i] : b[i];
22 return Result;
23}
24
25template<length_t L, typename T, typename U, qualifier Q>
26GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
27(
28 T x, const vec<L, U, Q>& a,
29 T y, const vec<L, U, Q>& b
30)
31{
32 vec<L, U, Q> Result;
33 for(length_t i = 0, n = Result.length(); i < n; ++i)
34 Result[i] = x < y ? a[i] : b[i];
35 return Result;
36}
37
38template<length_t L, typename T, typename U, qualifier Q>
39GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
40(
41 vec<L, T, Q> const& x, U a,
42 vec<L, T, Q> const& y, U b
43)
44{
45 vec<L, U, Q> Result;
46 for(length_t i = 0, n = Result.length(); i < n; ++i)
47 Result[i] = x[i] < y[i] ? a : b;
48 return Result;
49}
50
51// Min comparison between 3 variables
52template<typename T, typename U>
53GLM_FUNC_QUALIFIER U associatedMin
54(
55 T x, U a,
56 T y, U b,
57 T z, U c
58)
59{
60 U Result = x < y ? (x < z ? a : c) : (y < z ? b : c);
61 return Result;
62}
63
64template<length_t L, typename T, typename U, qualifier Q>
65GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
66(
67 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
68 vec<L, T, Q> const& y, vec<L, U, Q> const& b,
69 vec<L, T, Q> const& z, vec<L, U, Q> const& c
70)
71{
72 vec<L, U, Q> Result;
73 for(length_t i = 0, n = Result.length(); i < n; ++i)
74 Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]);
75 return Result;
76}
77
78// Min comparison between 4 variables
79template<typename T, typename U>
80GLM_FUNC_QUALIFIER U associatedMin
81(
82 T x, U a,
83 T y, U b,
84 T z, U c,
85 T w, U d
86)
87{
88 T Test1 = min(x, y);
89 T Test2 = min(z, w);
90 U Result1 = x < y ? a : b;
91 U Result2 = z < w ? c : d;
92 U Result = Test1 < Test2 ? Result1 : Result2;
93 return Result;
94}
95
96// Min comparison between 4 variables
97template<length_t L, typename T, typename U, qualifier Q>
98GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
99(
100 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
101 vec<L, T, Q> const& y, vec<L, U, Q> const& b,
102 vec<L, T, Q> const& z, vec<L, U, Q> const& c,
103 vec<L, T, Q> const& w, vec<L, U, Q> const& d
104)
105{
106 vec<L, U, Q> Result;
107 for(length_t i = 0, n = Result.length(); i < n; ++i)
108 {
109 T Test1 = min(x[i], y[i]);
110 T Test2 = min(z[i], w[i]);
111 U Result1 = x[i] < y[i] ? a[i] : b[i];
112 U Result2 = z[i] < w[i] ? c[i] : d[i];
113 Result[i] = Test1 < Test2 ? Result1 : Result2;
114 }
115 return Result;
116}
117
118// Min comparison between 4 variables
119template<length_t L, typename T, typename U, qualifier Q>
120GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
121(
122 T x, vec<L, U, Q> const& a,
123 T y, vec<L, U, Q> const& b,
124 T z, vec<L, U, Q> const& c,
125 T w, vec<L, U, Q> const& d
126)
127{
128 T Test1 = min(x, y);
129 T Test2 = min(z, w);
130
131 vec<L, U, Q> Result;
132 for(length_t i = 0, n = Result.length(); i < n; ++i)
133 {
134 U Result1 = x < y ? a[i] : b[i];
135 U Result2 = z < w ? c[i] : d[i];
136 Result[i] = Test1 < Test2 ? Result1 : Result2;
137 }
138 return Result;
139}
140
141// Min comparison between 4 variables
142template<length_t L, typename T, typename U, qualifier Q>
143GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMin
144(
145 vec<L, T, Q> const& x, U a,
146 vec<L, T, Q> const& y, U b,
147 vec<L, T, Q> const& z, U c,
148 vec<L, T, Q> const& w, U d
149)
150{
151 vec<L, U, Q> Result;
152 for(length_t i = 0, n = Result.length(); i < n; ++i)
153 {
154 T Test1 = min(x[i], y[i]);
155 T Test2 = min(z[i], w[i]);
156 U Result1 = x[i] < y[i] ? a : b;
157 U Result2 = z[i] < w[i] ? c : d;
158 Result[i] = Test1 < Test2 ? Result1 : Result2;
159 }
160 return Result;
161}
162
163// Max comparison between 2 variables
164template<typename T, typename U>
165GLM_FUNC_QUALIFIER U associatedMax(T x, U a, T y, U b)
166{
167 return x > y ? a : b;
168}
169
170// Max comparison between 2 variables
171template<length_t L, typename T, typename U, qualifier Q>
172GLM_FUNC_QUALIFIER vec<2, U, Q> associatedMax
173(
174 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
175 vec<L, T, Q> const& y, vec<L, U, Q> const& b
176)
177{
178 vec<L, U, Q> Result;
179 for(length_t i = 0, n = Result.length(); i < n; ++i)
180 Result[i] = x[i] > y[i] ? a[i] : b[i];
181 return Result;
182}
183
184// Max comparison between 2 variables
185template<length_t L, typename T, typename U, qualifier Q>
186GLM_FUNC_QUALIFIER vec<L, T, Q> associatedMax
187(
188 T x, vec<L, U, Q> const& a,
189 T y, vec<L, U, Q> const& b
190)
191{
192 vec<L, U, Q> Result;
193 for(length_t i = 0, n = Result.length(); i < n; ++i)
194 Result[i] = x > y ? a[i] : b[i];
195 return Result;
196}
197
198// Max comparison between 2 variables
199template<length_t L, typename T, typename U, qualifier Q>
200GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
201(
202 vec<L, T, Q> const& x, U a,
203 vec<L, T, Q> const& y, U b
204)
205{
206 vec<L, T, Q> Result;
207 for(length_t i = 0, n = Result.length(); i < n; ++i)
208 Result[i] = x[i] > y[i] ? a : b;
209 return Result;
210}
211
212// Max comparison between 3 variables
213template<typename T, typename U>
214GLM_FUNC_QUALIFIER U associatedMax
215(
216 T x, U a,
217 T y, U b,
218 T z, U c
219)
220{
221 U Result = x > y ? (x > z ? a : c) : (y > z ? b : c);
222 return Result;
223}
224
225// Max comparison between 3 variables
226template<length_t L, typename T, typename U, qualifier Q>
227GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
228(
229 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
230 vec<L, T, Q> const& y, vec<L, U, Q> const& b,
231 vec<L, T, Q> const& z, vec<L, U, Q> const& c
232)
233{
234 vec<L, U, Q> Result;
235 for(length_t i = 0, n = Result.length(); i < n; ++i)
236 Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]);
237 return Result;
238}
239
240// Max comparison between 3 variables
241template<length_t L, typename T, typename U, qualifier Q>
242GLM_FUNC_QUALIFIER vec<L, T, Q> associatedMax
243(
244 T x, vec<L, U, Q> const& a,
245 T y, vec<L, U, Q> const& b,
246 T z, vec<L, U, Q> const& c
247)
248{
249 vec<L, U, Q> Result;
250 for(length_t i = 0, n = Result.length(); i < n; ++i)
251 Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]);
252 return Result;
253}
254
255// Max comparison between 3 variables
256template<length_t L, typename T, typename U, qualifier Q>
257GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
258(
259 vec<L, T, Q> const& x, U a,
260 vec<L, T, Q> const& y, U b,
261 vec<L, T, Q> const& z, U c
262)
263{
264 vec<L, T, Q> Result;
265 for(length_t i = 0, n = Result.length(); i < n; ++i)
266 Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c);
267 return Result;
268}
269
270// Max comparison between 4 variables
271template<typename T, typename U>
272GLM_FUNC_QUALIFIER U associatedMax
273(
274 T x, U a,
275 T y, U b,
276 T z, U c,
277 T w, U d
278)
279{
280 T Test1 = max(x, y);
281 T Test2 = max(z, w);
282 U Result1 = x > y ? a : b;
283 U Result2 = z > w ? c : d;
284 U Result = Test1 > Test2 ? Result1 : Result2;
285 return Result;
286}
287
288// Max comparison between 4 variables
289template<length_t L, typename T, typename U, qualifier Q>
290GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
291(
292 vec<L, T, Q> const& x, vec<L, U, Q> const& a,
293 vec<L, T, Q> const& y, vec<L, U, Q> const& b,
294 vec<L, T, Q> const& z, vec<L, U, Q> const& c,
295 vec<L, T, Q> const& w, vec<L, U, Q> const& d
296)
297{
298 vec<L, U, Q> Result;
299 for(length_t i = 0, n = Result.length(); i < n; ++i)
300 {
301 T Test1 = max(x[i], y[i]);
302 T Test2 = max(z[i], w[i]);
303 U Result1 = x[i] > y[i] ? a[i] : b[i];
304 U Result2 = z[i] > w[i] ? c[i] : d[i];
305 Result[i] = Test1 > Test2 ? Result1 : Result2;
306 }
307 return Result;
308}
309
310// Max comparison between 4 variables
311template<length_t L, typename T, typename U, qualifier Q>
312GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
313(
314 T x, vec<L, U, Q> const& a,
315 T y, vec<L, U, Q> const& b,
316 T z, vec<L, U, Q> const& c,
317 T w, vec<L, U, Q> const& d
318)
319{
320 T Test1 = max(x, y);
321 T Test2 = max(z, w);
322
323 vec<L, U, Q> Result;
324 for(length_t i = 0, n = Result.length(); i < n; ++i)
325 {
326 U Result1 = x > y ? a[i] : b[i];
327 U Result2 = z > w ? c[i] : d[i];
328 Result[i] = Test1 > Test2 ? Result1 : Result2;
329 }
330 return Result;
331}
332
333// Max comparison between 4 variables
334template<length_t L, typename T, typename U, qualifier Q>
335GLM_FUNC_QUALIFIER vec<L, U, Q> associatedMax
336(
337 vec<L, T, Q> const& x, U a,
338 vec<L, T, Q> const& y, U b,
339 vec<L, T, Q> const& z, U c,
340 vec<L, T, Q> const& w, U d
341)
342{
343 vec<L, U, Q> Result;
344 for(length_t i = 0, n = Result.length(); i < n; ++i)
345 {
346 T Test1 = max(x[i], y[i]);
347 T Test2 = max(z[i], w[i]);
348 U Result1 = x[i] > y[i] ? a : b;
349 U Result2 = z[i] > w[i] ? c : d;
350 Result[i] = Test1 > Test2 ? Result1 : Result2;
351 }
352 return Result;
353}
354}//namespace glm
GLM_FUNC_DECL GLM_CONSTEXPR genType min(genType x, genType y)
Definition func_common.inl:17
GLM_FUNC_DECL GLM_CONSTEXPR genType max(genType x, genType y)
Definition func_common.inl:25
GLM_FUNC_DECL U associatedMax(T x, U a, T y, U b)
Definition associated_min_max.inl:165
GLM_FUNC_DECL U associatedMin(T x, U a, T y, U b)
Definition associated_min_max.inl:7
Core features
Definition common.hpp:21
Definition qualifier.hpp:35