Blender V5.3
math_float3.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2013 Intel Corporation
2 * SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: Apache-2.0 */
5
6#pragma once
7
8#include "util/math_base.h"
9#include "util/math_float4.h"
10#include "util/types_float3.h"
11#include "util/types_float4.h"
12#include "util/types_int3.h"
13#include "util/types_uint3.h"
14
16
18{
19#ifdef __KERNEL_SSE__
20 return float3(_mm_setzero_ps());
21#else
22 return make_float3(0.0f, 0.0f, 0.0f);
23#endif
24}
25
27{
28 return make_float3(1.0f, 1.0f, 1.0f);
29}
30
35
37{
38#ifdef __KERNEL_SSE__
39 /* Don't use _mm_rcp_ps due to poor precision. */
40 return float3(_mm_div_ps(_mm_set_ps1(1.0f), a.m128));
41#else
42 return make_float3(1.0f / a.x, 1.0f / a.y, 1.0f / a.z);
43#endif
44}
45
46#ifndef __KERNEL_METAL__
47
49{
50# ifdef __KERNEL_SSE__
51 return float3(_mm_xor_ps(a.m128, _mm_castsi128_ps(_mm_set1_epi32(0x80000000))));
52# else
53 return make_float3(-a.x, -a.y, -a.z);
54# endif
55}
56
58{
59# ifdef __KERNEL_SSE__
60 return float3(_mm_mul_ps(a.m128, b.m128));
61# else
62 return make_float3(a.x * b.x, a.y * b.y, a.z * b.z);
63# endif
64}
65
67{
68# ifdef __KERNEL_SSE__
69 return float3(_mm_mul_ps(a.m128, _mm_set1_ps(f)));
70# else
71 return make_float3(a.x * f, a.y * f, a.z * f);
72# endif
73}
74
76{
77# if defined(__KERNEL_SSE__)
78 return float3(_mm_mul_ps(_mm_set1_ps(f), a.m128));
79# else
80 return make_float3(a.x * f, a.y * f, a.z * f);
81# endif
82}
83
85{
86# if defined(__KERNEL_SSE__)
87 return float3(_mm_div_ps(_mm_set1_ps(f), a.m128));
88# else
89 return make_float3(f / a.x, f / a.y, f / a.z);
90# endif
91}
92
94{
95# if defined(__KERNEL_SSE__)
96 return float3(_mm_div_ps(a.m128, _mm_set1_ps(f)));
97# else
98 float invf = 1.0f / f;
99 return make_float3(a.x * invf, a.y * invf, a.z * invf);
100# endif
101}
102
104{
105# if defined(__KERNEL_SSE__)
106 return float3(_mm_div_ps(a.m128, b.m128));
107# else
108 return make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
109# endif
110}
111
113{
114# ifdef __KERNEL_SSE__
115 return float3(_mm_add_ps(a.m128, b.m128));
116# else
117 return make_float3(a.x + b.x, a.y + b.y, a.z + b.z);
118# endif
119}
120
122{
123 return a + make_float3(b);
124}
125
127{
128 return make_float3(a) + b;
129}
130
132{
133# ifdef __KERNEL_SSE__
134 return float3(_mm_sub_ps(a.m128, b.m128));
135# else
136 return make_float3(a.x - b.x, a.y - b.y, a.z - b.z);
137# endif
138}
139
141{
142 return a - make_float3(b);
143}
144
146{
147 return make_float3(a) - b;
148}
149
151{
152 return a = a + b;
153}
154
156{
157 return a = a - b;
158}
159
161{
162 return a = a * b;
163}
164
166{
167 return a = a * f;
168}
169
171{
172 return a = a / b;
173}
174
176{
177 const float invf = 1.0f / f;
178 return a = a * invf;
179}
180
181# if !(defined(__KERNEL_CUDA__) || defined(__KERNEL_HIP__) || defined(__KERNEL_ONEAPI__))
183{
184 a = float3(a) * b;
185 return a;
186}
187
189{
190 a = float3(a) * f;
191 return a;
192}
193
195{
196 a = float3(a) / b;
197 return a;
198}
199
201{
202 a = float3(a) / f;
203 return a;
204}
205
207{
208 a = float3(a) + b;
209 return a;
210}
211# endif
212
214{
215# ifdef __KERNEL_SSE__
216 return (_mm_movemask_ps(_mm_cmpeq_ps(a.m128, b.m128)) & 7) == 7;
217# else
218 return (a.x == b.x && a.y == b.y && a.z == b.z);
219# endif
220}
221
223{
224# ifdef __KERNEL_SSE__
225 return int3(_mm_castps_si128(_mm_cmpeq_ps(a.m128, make_float3(b).m128)));
226# else
227 return make_int3(a.x == b, a.y == b, a.z == b);
228# endif
229}
230
232{
233 return !(a == b);
234}
235
237{
238# ifdef __KERNEL_SSE__
239 return int3(_mm_castps_si128(_mm_cmpge_ps(a.m128, b.m128)));
240# else
241 return make_int3(a.x >= b.x, a.y >= b.y, a.z >= b.z);
242# endif
243}
244
246{
247# ifdef __KERNEL_SSE__
248 return int3(_mm_castps_si128(_mm_cmplt_ps(a.m128, b.m128)));
249# else
250 return make_int3(a.x < b.x, a.y < b.y, a.z < b.z);
251# endif
252}
253
254ccl_device_inline float dot(const float3 a, const float3 b)
255{
256# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
257 return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F));
258# else
259 return a.x * b.x + a.y * b.y + a.z * b.z;
260# endif
261}
262
264{
265# ifdef __KERNEL_SSE__
266 return int3(_mm_castps_si128(_mm_cmpgt_ps(a.m128, b.m128)));
267# else
268 return make_int3(a.x > b.x, a.y > b.y, a.z > b.z);
269# endif
270}
271
273{
274 return a > make_float3(b);
275}
276
277#endif /* __KERNEL_METAL__ */
278
280{
281#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
282 return _mm_cvtss_f32(_mm_hadd_ps(_mm_mul_ps(a, b), b));
283#else
284 return a.x * b.x + a.y * b.y;
285#endif
286}
287
289{
290#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
291 return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F)));
292#else
293 return sqrtf(dot(a, a));
294#endif
295}
296
298{
299 return min(min(a.x, a.y), a.z);
300}
301
303{
304 return max(max(a.x, a.y), a.z);
305}
306
308{
309 return dot(a, a);
310}
311
312#ifndef __KERNEL_METAL__
313
315{
316 return len(a - b);
317}
318
320{
321# ifdef __KERNEL_SSE__
322 const float4 x = float4(a.m128);
323 const float4 y = shuffle<1, 2, 0, 3>(float4(b.m128));
324 const float4 z = float4(_mm_mul_ps(shuffle<1, 2, 0, 3>(float4(a.m128)), float4(b.m128)));
325
326 return float3(shuffle<1, 2, 0, 3>(msub(x, y, z)).m128);
327# else
328 return make_float3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
329# endif
330}
331
333{
334# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
335 const __m128 norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F));
336 return float3(_mm_div_ps(a.m128, norm));
337# else
338 return a / len(a);
339# endif
340}
341
343{
344# ifdef __KERNEL_SSE__
345 return float3(_mm_min_ps(a.m128, b.m128));
346# else
347 return make_float3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
348# endif
349}
350
352{
353# ifdef __KERNEL_SSE__
354 return float3(_mm_max_ps(a.m128, b.m128));
355# else
356 return make_float3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
357# endif
358}
359
360ccl_device_inline float3 clamp(const float3 a, const float3 mn, const float3 mx)
361{
362 return min(max(a, mn), mx);
363}
364
366{
367# ifdef __KERNEL_SSE__
368# ifdef __KERNEL_NEON__
369 return float3(vabsq_f32(a.m128));
370# else
371 __m128 mask = _mm_castsi128_ps(_mm_set1_epi32(0x7fffffff));
372 return float3(_mm_and_ps(a.m128, mask));
373# endif
374# else
375 return make_float3(fabsf(a.x), fabsf(a.y), fabsf(a.z));
376# endif
377}
378
379/* The floating-point remainder of the division operation a / b calculated by this function is
380 * exactly the value a - iquot * b, where iquot is a / b with its fractional part truncated.
381 *
382 * The returned value has the same sign as a and is less than b in magnitude. */
383ccl_device_inline float3 fmod(const float3 a, const float b)
384{
385# if defined(__KERNEL_NEON__)
386 /* Use native Neon instructions.
387 * The logic is the same as the SSE code below, but on Apple M2 Ultra this seems to be faster.
388 * Possibly due to some runtime checks in _mm_round_ps which do not get properly inlined. */
389 const float32x4_t iquot = vrndq_f32(a / b);
390 return float3(vsubq_f32(a, vmulq_f32(iquot, vdupq_n_f32(b))));
391# elif defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
392 const __m128 iquot = _mm_round_ps(a / b, _MM_FROUND_TRUNC);
393 return float3(_mm_sub_ps(a, _mm_mul_ps(iquot, _mm_set1_ps(b))));
394# else
395 return make_float3(fmodf(a.x, b), fmodf(a.y, b), fmodf(a.z, b));
396# endif
397}
398
400{
401# if defined(__KERNEL_NEON__)
402 const float32x4_t iquot = vrndq_f32(vdivq_f32(a.m128, b.m128));
403 return float3(vsubq_f32(a, vmulq_f32(iquot, b.m128)));
404# elif defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__)
405 const __m128 div = _mm_div_ps(a.m128, b.m128);
406 const __m128 iquot = _mm_round_ps(div, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
407 return float3(_mm_sub_ps(a.m128, _mm_mul_ps(iquot, b.m128)));
408# else
409 return make_float3(fmodf(a.x, b.x), fmodf(a.y, b.y), fmodf(a.z, b.z));
410# endif
411}
412
414{
415# ifdef __KERNEL_SSE__
416 return float3(_mm_sqrt_ps(a));
417# else
418 return make_float3(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z));
419# endif
420}
421
423{
424# if defined(__KERNEL_NEON__)
425 return float3(vrndnq_f32(a.m128));
426# elif defined(__KERNEL_SSE__)
427 return float3(_mm_round_ps(a.m128, _MM_FROUND_NINT));
428# else
429 return make_float3(roundf(a.x), roundf(a.y), roundf(a.z));
430# endif
431}
432
434{
435# ifdef __KERNEL_SSE__
436 return float3(_mm_floor_ps(a));
437# else
438 return make_float3(floorf(a.x), floorf(a.y), floorf(a.z));
439# endif
440}
441
443{
444# ifdef __KERNEL_SSE__
445 return float3(_mm_ceil_ps(a));
446# else
447 return make_float3(ceilf(a.x), ceilf(a.y), ceilf(a.z));
448# endif
449}
450
455
457{
458 return make_float3(expf(v.x), expf(v.y), expf(v.z));
459}
460
462{
463 return make_float3(logf(v.x), logf(v.y), logf(v.z));
464}
465
467{
468 return make_float3(sinf(v.x), sinf(v.y), sinf(v.z));
469}
470
472{
473 return make_float3(cosf(v.x), cosf(v.y), cosf(v.z));
474}
475
477{
478 return make_float3(tanf(v.x), tanf(v.y), tanf(v.z));
479}
480
482{
483 return make_float3(atan2f(y.x, x.x), atan2f(y.y, x.y), atan2f(y.z, x.z));
484}
485
486ccl_device_inline float3 reflect(const float3 incident, const float3 unit_normal)
487{
488 return incident - 2.0f * unit_normal * dot(incident, unit_normal);
489}
490
491ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)
492{
493 const float k = 1.0f - eta * eta * (1.0f - dot(normal, incident) * dot(normal, incident));
494 if (k < 0.0f) {
495 return zero_float3();
496 }
497 return eta * incident - (eta * dot(normal, incident) + sqrt(k)) * normal;
498}
499
501 const float3 incident,
502 const float3 reference)
503{
504 return (dot(reference, incident) < 0.0f) ? vector : -vector;
505}
506
507#endif /* !__KERNEL_METAL__ */
508
510{
511 return sqrt(max(a, zero_float3()));
512}
513
515{
516 const float len_squared = dot(v_proj, v_proj);
517 return (len_squared != 0.0f) ? (dot(v, v_proj) / len_squared) * v_proj : zero_float3();
518}
519
521{
522 *t = len(a);
523 const float x = 1.0f / *t;
524 return a * x;
525}
526
528{
529 const float t = len(a);
530 return (t != 0.0f) ? a * (1.0f / t) : a;
531}
532
534{
535 const float t = len(a);
536 return (t != 0.0f) ? a * (1.0f / t) : fallback;
537}
538
540{
541 *t = len(a);
542 return (*t != 0.0f) ? a / (*t) : a;
543}
544
546{
547 return make_float3((b.x != 0.0f) ? a.x / b.x : 0.0f,
548 (b.y != 0.0f) ? a.y / b.y : 0.0f,
549 (b.z != 0.0f) ? a.z / b.z : 0.0f);
550}
551
553{
554 return (b != 0.0f) ? a / b : zero_float3();
555}
556
557ccl_device_inline float3 interp(const float3 a, const float3 b, const float t)
558{
559 return a + t * (b - a);
560}
561
563{
564 return a * a;
565}
566
568{
569#ifdef __KERNEL_SSE__
570 return a == make_float3(0.0f);
571#else
572 return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f);
573#endif
574}
575
577{
578 return (a.x == 0.0f || a.y == 0.0f || a.z == 0.0f);
579}
580
582{
583#if defined(__KERNEL_SSE__) && defined(__KERNEL_NEON__)
584 __m128 t = a.m128;
585 t = vsetq_lane_f32(0.0f, t, 3);
586 return vaddvq_f32(t);
587#else
588 return (a.x + a.y + a.z);
589#endif
590}
591
593{
594 return reduce_add(a) * (1.0f / 3.0f);
595}
596
598{
599#if defined(__KERNEL_METAL__)
600 return all(a == b);
601#else
602 return a == b;
603#endif
604}
605
606template<class MaskType>
607ccl_device_inline float3 select(const MaskType mask, const float3 a, const float3 b)
608{
609#if defined(__KERNEL_METAL__)
610 return metal::select(b, a, bool3(mask));
611#elif defined(__KERNEL_SSE__)
612# ifdef __KERNEL_SSE42__
613 return float3(_mm_blendv_ps(b.m128, a.m128, _mm_castsi128_ps(mask.m128)));
614# else
615 return float3(
616 _mm_or_ps(_mm_and_ps(_mm_castsi128_ps(mask), a), _mm_andnot_ps(_mm_castsi128_ps(mask), b)));
617# endif
618#else
619 return make_float3((mask.x) ? a.x : b.x, (mask.y) ? a.y : b.y, (mask.z) ? a.z : b.z);
620#endif
621}
622
623template<class MaskType> ccl_device_inline float3 mask(const MaskType mask, const float3 a)
624{
625 /* Replace elements of x with zero where mask isn't set. */
626 return select(mask, a, zero_float3());
627}
628
629/* Consistent name for this would be pow, but HIP compiler crashes in name mangling. */
630ccl_device_inline float3 power(const float3 v, const float e)
631{
632 return make_float3(powf(v.x, e), powf(v.y, e), powf(v.z, e));
633}
634
636{
637 return make_float3(safe_powf(a.x, b.x), safe_powf(a.y, b.y), safe_powf(a.z, b.z));
638}
639
641{
642 return select(v > zero_float3(), log(v), zero_float3());
643}
644
646{
647#if defined(__KERNEL_METAL__)
648 *sine = sincos(x, *cosine);
649#else
650 *sine = sin(x);
651 *cosine = cos(x);
652#endif
653}
654
656{
657#if defined(__KERNEL_METAL__)
658 return a == b;
659#elif defined __KERNEL_NEON__
660 return int3(vreinterpretq_m128i_u32(vceqq_f32(a.m128, b.m128)));
661#elif defined(__KERNEL_SSE__)
662 return int3(_mm_castps_si128(_mm_cmpeq_ps(a.m128, b.m128)));
663#else
664 return make_int3(a.x == b.x, a.y == b.y, a.z == b.z);
665#endif
666}
667
672
674{
675 return select(component_is_zero(b), zero_float3(), a - floor(a / b) * b);
676}
677
679{
680 return safe_floored_fmod(value - min, max - min) + min;
681}
682
684{
685 return select(component_is_zero(b), zero_float3(), fmod(a, b));
686}
687
692
694{
695 return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z);
696}
697
699{
700 float3 r = v;
701 if (!isfinite_safe(r.x)) {
702 r.x = 0.0f;
703 }
704 if (!isfinite_safe(r.y)) {
705 r.y = 0.0f;
706 }
707 if (!isfinite_safe(r.z)) {
708 r.z = 0.0f;
709 }
710 return r;
711}
712
713/* Triangle */
714
716 const ccl_private float3 &v2,
717 const ccl_private float3 &v3)
718{
719 return len(cross(v3 - v2, v1 - v2)) * 0.5f;
720}
721
722/* Orthonormal vectors */
723
727{
728#if 0
729 if (fabsf(N.y) >= 0.999f) {
730 *a = make_float3(1, 0, 0);
731 *b = make_float3(0, 0, 1);
732 return;
733 }
734 if (fabsf(N.z) >= 0.999f) {
735 *a = make_float3(1, 0, 0);
736 *b = make_float3(0, 1, 0);
737 return;
738 }
739#endif
740
741 if (N.x != N.y || N.x != N.z) {
742 *a = make_float3(N.z - N.y, N.x - N.z, N.y - N.x); //(1,1,1)x N
743 }
744 else {
745 *a = make_float3(N.z - N.y, N.x + N.z, -N.y - N.x); //(-1,1,1)x N
746 }
747
748 *a = normalize(*a);
749 *b = cross(N, *a);
750}
751
752/* Rotation of point around axis and angle */
753
755{
756 const float costheta = cosf(angle);
757 const float sintheta = sinf(angle);
758 float3 r;
759
760 r.x = ((costheta + (1 - costheta) * axis.x * axis.x) * p.x) +
761 (((1 - costheta) * axis.x * axis.y - axis.z * sintheta) * p.y) +
762 (((1 - costheta) * axis.x * axis.z + axis.y * sintheta) * p.z);
763
764 r.y = (((1 - costheta) * axis.x * axis.y + axis.z * sintheta) * p.x) +
765 ((costheta + (1 - costheta) * axis.y * axis.y) * p.y) +
766 (((1 - costheta) * axis.y * axis.z - axis.x * sintheta) * p.z);
767
768 r.z = (((1 - costheta) * axis.x * axis.z - axis.y * sintheta) * p.x) +
769 (((1 - costheta) * axis.y * axis.z + axis.x * sintheta) * p.y) +
770 ((costheta + (1 - costheta) * axis.z * axis.z) * p.z);
771
772 return r;
773}
774
775/* Calculate the angle between the two vectors a and b.
776 * The usual approach `acos(dot(a, b))` has severe precision issues for small angles,
777 * which are avoided by this method.
778 * Based on "Mangled Angles" from https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf
779 */
781{
782 return 2.0f * atan2f(len(a - b), len(a + b));
783}
784
785/* Tangent of the angle between vectors a and b. */
787{
788 return len(cross(a, b)) / dot(a, b);
789}
790
791/* projections */
793{
794 float len;
795 float u;
796 float v;
797 len = sqrtf(co.x * co.x + co.y * co.y);
798 if (len > 0.0f) {
799 u = (1.0f - (atan2f(co.x / len, co.y / len) / M_PI_F)) * 0.5f;
800 v = (co.z + 1.0f) * 0.5f;
801 }
802 else {
803 u = v = 0.0f;
804 }
805 return make_float2(u, v);
806}
807
809{
810 const float l = dot(co, co);
811 float u;
812 float v;
813 if (l > 0.0f) {
814 if (UNLIKELY(co.x == 0.0f && co.y == 0.0f)) {
815 u = 0.0f; /* Otherwise domain error. */
816 }
817 else {
818 u = (0.5f - atan2f(co.x, co.y) * M_1_2PI_F);
819 }
820 v = 1.0f - safe_acosf(co.z / sqrtf(l)) * M_1_PI_F;
821 }
822 else {
823 u = v = 0.0f;
824 }
825 return make_float2(u, v);
826}
827
829{
830 r[0] = val.x;
831 r[1] = val.y;
832 r[2] = val.z;
833}
834
836{
837#ifdef __KERNEL_METAL__
838 return as_type<uint3>(f);
839#else
841#endif
842}
843
845{
846#ifdef __KERNEL_METAL__
847 return as_type<float3>(f);
848#else
850#endif
851}
852
#define UNLIKELY(x)
btScalar max
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition btVector3.h:263
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define ccl_private
#define ccl_device_inline
#define M_1_PI_F
#define M_1_2PI_F
#define ccl_device_template_spec
#define logf(x)
#define expf(x)
#define powf(x, y)
#define CCL_NAMESPACE_END
#define saturatef(x)
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline uint3 make_uint3(const uint x, const uint y, const uint z)
#define fmodf(x, y)
#define roundf(x)
ccl_device_forceinline int3 make_int3(const int x, const int y, const int z)
#define __float_as_uint(x)
#define __uint_as_float(x)
#define tan
#define log
#define sin
#define round
VecBase< T, D > refract(VecOp< T, D >, VecOp< T, D >, float) RET
#define exp
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
#define cos
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
VecBase< T, D > faceforward(VecOp< T, D >, VecOp< T, D >, VecOp< T, D >) RET
#define select(A, B, C)
#define floor
float distance(float, float) RET
#define ceil
bool all(VecOp< bool, D >) RET
#define sqrt
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
constexpr T clamp(T, U, U) RET
VecBase< bool, 3 > bool3
float3 rotate_around_axis(float3 p, float3 axis, float angle)
#define atan2
bool is_zero(float3x3 a)
float wrap(float a, float b, float c)
float safe_divide(float a, float b)
float safe_sqrt(float a)
float reduce_add(float2 a)
float reduce_min(float2 a)
float average(float2 a)
float reduce_max(float2 a)
VecT safe_normalize(VecT vector)
__forceinline LightTreeMeasure operator+(const LightTreeMeasure &a, const LightTreeMeasure &b)
ccl_device_inline Interval< T1 > operator/=(ccl_private Interval< T1 > &interval, const T2 f)
Definition math_base.h:938
ccl_device float safe_powf(const float a, const float b)
Definition math_base.h:618
ccl_device_inline Extrema< T > operator*(const Extrema< T > a, const T b)
Definition math_base.h:967
ccl_device_inline Extrema< T > operator+=(ccl_private Extrema< T > &a, const ccl_private Extrema< T > &b)
Definition math_base.h:980
ccl_device float safe_acosf(const float a)
Definition math_base.h:590
ccl_device_inline float compatible_signf(const float f)
Definition math_base.h:524
ccl_device_inline float ensure_finite(const float v)
Definition math_base.h:370
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:549
ccl_device_inline bool isfinite_safe(const float f)
Definition math_base.h:362
ccl_device_inline T make_zero()
Definition math_dual.h:20
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
ccl_device_inline dual< T > safe_pow(const ccl_private dual< T > &u, const ccl_private dual< T > &v)
Definition math_dual.h:393
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &a)
Definition math_dual.h:273
ccl_device_inline dual< T > operator/(const dual< T > a, T b)
Definition math_dual.h:71
ccl_device_inline dual3 safe_floored_fmod(const dual3 a, const dual3 b)
Definition math_dual.h:204
ccl_device_inline dual2 map_to_tube(const dual3 co)
Definition math_dual.h:404
ccl_device_inline dual2 map_to_sphere(const dual3 co)
Definition math_dual.h:418
ccl_device_inline dual< T1 > operator-(const dual< T1 > a, T2 b)
Definition math_dual.h:113
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
ccl_device_inline bool operator<(const ccl_private dual1 &a, const float b)
Definition math_dual.h:45
ccl_device_inline dual< T > compatible_sign(const ccl_private dual< T > &u)
Definition math_dual.h:193
ccl_device_inline dual3 safe_fmod(const dual3 u, const dual3 v)
Definition math_dual.h:199
ccl_device_inline float2 power(const float2 v, const float e)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline bool operator!=(const float2 a, const float2 b)
ccl_device_inline float2 normalize_len(const float2 a, ccl_private float *t)
ccl_device_inline bool isequal(const float2 a, const float2 b)
ccl_device_inline bool operator==(const float2 a, const float2 b)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ccl_device_inline int2 operator>=(const float2 a, const float2 b)
ccl_device_inline float2 operator*=(float2 &a, const float2 b)
Definition math_float2.h:90
ccl_device_inline float3 reciprocal(const float3 a)
Definition math_float3.h:36
ccl_device_inline void copy_v3_v3(ccl_private float *r, const float3 val)
ccl_device_inline float precise_angle(const float3 a, const float3 b)
ccl_device_inline float3 safe_normalize_fallback(const float3 a, const float3 fallback)
ccl_device_inline void sincos(const float3 x, ccl_private float3 *sine, ccl_private float3 *cosine)
ccl_device_inline float3 one_float3()
Definition math_float3.h:26
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
ccl_device_inline float dot_xy(const float3 a, const float3 b)
ccl_device_inline bool any_zero(const float3 a)
ccl_device_inline float3 uint3_as_float3(const uint3 f)
ccl_device_inline float triangle_area(const ccl_private float3 &v1, const ccl_private float3 &v2, const ccl_private float3 &v3)
ccl_device_inline uint3 float3_as_uint3(const float3 f)
ccl_device_inline float3 safe_normalize_len(const float3 a, ccl_private float *t)
ccl_device_inline int3 operator>(const float3 a, const float3 b)
ccl_device_inline auto component_is_zero(const float3 a)
ccl_device_inline void make_orthonormals(const float3 N, ccl_private float3 *a, ccl_private float3 *b)
ccl_device_inline float3 operator-=(float3 &a, const float3 b)
ccl_device_inline auto component_wise_equal(const float3 a, const float3 b)
ccl_device_inline float tan_angle(const float3 a, const float3 b)
ccl_device_inline float4 msub(const float4 a, const float4 b, const float4 c)
#define N
vector project(vector v, vector v_proj)
Definition node_math.h:141
float safe_log(float a, float b)
Definition node_math.h:136
#define sqr
#define floorf
#define fabsf
#define sqrtf
#define sinf
#define make_float2
#define tanf
#define M_PI_F
#define cosf
#define ceilf
#define atan2f
#define saturate(a)
Definition smaa.cc:319
#define min(a, b)
Definition sort.cc:38
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
uint y
Definition types_uint3.h:13
uint z
Definition types_uint3.h:13
uint x
Definition types_uint3.h:13