Blender V5.0
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
451ccl_device_inline float3 mix(const float3 a, const float3 b, const float t)
452{
453 return a + t * (b - a);
454}
455
457{
458 return a + t * (b - a);
459}
460
465
467{
468 return make_float3(expf(v.x), expf(v.y), expf(v.z));
469}
470
472{
473 return make_float3(logf(v.x), logf(v.y), logf(v.z));
474}
475
477{
478 return make_float3(sinf(v.x), sinf(v.y), sinf(v.z));
479}
480
482{
483 return make_float3(cosf(v.x), cosf(v.y), cosf(v.z));
484}
485
487{
488 return make_float3(tanf(v.x), tanf(v.y), tanf(v.z));
489}
490
492{
493 return make_float3(atan2f(y.x, x.x), atan2f(y.y, x.y), atan2f(y.z, x.z));
494}
495
496ccl_device_inline float3 reflect(const float3 incident, const float3 unit_normal)
497{
498 return incident - 2.0f * unit_normal * dot(incident, unit_normal);
499}
500
501ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)
502{
503 const float k = 1.0f - eta * eta * (1.0f - dot(normal, incident) * dot(normal, incident));
504 if (k < 0.0f) {
505 return zero_float3();
506 }
507 return eta * incident - (eta * dot(normal, incident) + sqrt(k)) * normal;
508}
509
511 const float3 incident,
512 const float3 reference)
513{
514 return (dot(reference, incident) < 0.0f) ? vector : -vector;
515}
516#endif
517
519{
520 return sqrt(max(a, zero_float3()));
521}
522
524{
525 const float len_squared = dot(v_proj, v_proj);
526 return (len_squared != 0.0f) ? (dot(v, v_proj) / len_squared) * v_proj : zero_float3();
527}
528
530{
531 *t = len(a);
532 const float x = 1.0f / *t;
533 return a * x;
534}
535
537{
538 const float t = len(a);
539 return (t != 0.0f) ? a * (1.0f / t) : a;
540}
541
543{
544 const float t = len(a);
545 return (t != 0.0f) ? a * (1.0f / t) : fallback;
546}
547
549{
550 *t = len(a);
551 return (*t != 0.0f) ? a / (*t) : a;
552}
553
555{
556 return make_float3((b.x != 0.0f) ? a.x / b.x : 0.0f,
557 (b.y != 0.0f) ? a.y / b.y : 0.0f,
558 (b.z != 0.0f) ? a.z / b.z : 0.0f);
559}
560
562{
563 return (b != 0.0f) ? a / b : zero_float3();
564}
565
566ccl_device_inline float3 interp(const float3 a, const float3 b, const float t)
567{
568 return a + t * (b - a);
569}
570
572{
573 return a * a;
574}
575
577{
578#ifdef __KERNEL_SSE__
579 return a == make_float3(0.0f);
580#else
581 return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f);
582#endif
583}
584
586{
587 return (a.x == 0.0f || a.y == 0.0f || a.z == 0.0f);
588}
589
591{
592#if defined(__KERNEL_SSE__) && defined(__KERNEL_NEON__)
593 __m128 t = a.m128;
594 t = vsetq_lane_f32(0.0f, t, 3);
595 return vaddvq_f32(t);
596#else
597 return (a.x + a.y + a.z);
598#endif
599}
600
602{
603 return reduce_add(a) * (1.0f / 3.0f);
604}
605
607{
608#if defined(__KERNEL_METAL__)
609 return all(a == b);
610#else
611 return a == b;
612#endif
613}
614
615template<class MaskType>
616ccl_device_inline float3 select(const MaskType mask, const float3 a, const float3 b)
617{
618#if defined(__KERNEL_METAL__)
619 return metal::select(b, a, bool3(mask));
620#elif defined(__KERNEL_SSE__)
621# ifdef __KERNEL_SSE42__
622 return float3(_mm_blendv_ps(b.m128, a.m128, _mm_castsi128_ps(mask.m128)));
623# else
624 return float4(
625 _mm_or_ps(_mm_and_ps(_mm_castsi128_ps(mask), a), _mm_andnot_ps(_mm_castsi128_ps(mask), b)));
626# endif
627#else
628 return make_float3((mask.x) ? a.x : b.x, (mask.y) ? a.y : b.y, (mask.z) ? a.z : b.z);
629#endif
630}
631
632template<class MaskType> ccl_device_inline float3 mask(const MaskType mask, const float3 a)
633{
634 /* Replace elements of x with zero where mask isn't set. */
635 return select(mask, a, zero_float3());
636}
637
638/* Consistent name for this would be pow, but HIP compiler crashes in name mangling. */
640{
641 return make_float3(powf(v.x, e), powf(v.y, e), powf(v.z, e));
642}
643
645{
646 return make_float3(safe_powf(a.x, b.x), safe_powf(a.y, b.y), safe_powf(a.z, b.z));
647}
648
650{
651#if defined(__KERNEL_METAL__)
652 return a == b;
653#elif defined __KERNEL_NEON__
654 return int3(vreinterpretq_m128i_s32(vceqq_f32(a.m128, b.m128)));
655#elif defined(__KERNEL_SSE__)
656 return int3(_mm_castps_si128(_mm_cmpeq_ps(a.m128, b.m128)));
657#else
658 return make_int3(a.x == b.x, a.y == b.y, a.z == b.z);
659#endif
660}
661
663{
664 return isequal_mask(a, zero_float3());
665}
666
668{
669 return select(is_zero_mask(b), zero_float3(), a - floor(a / b) * b);
670}
671
673{
674 return safe_floored_fmod(value - min, max - min) + min;
675}
676
678{
679 return select(is_zero_mask(b), zero_float3(), fmod(a, b));
680}
681
686
688{
689 return isfinite_safe(v.x) && isfinite_safe(v.y) && isfinite_safe(v.z);
690}
691
693{
694 float3 r = v;
695 if (!isfinite_safe(r.x)) {
696 r.x = 0.0f;
697 }
698 if (!isfinite_safe(r.y)) {
699 r.y = 0.0f;
700 }
701 if (!isfinite_safe(r.z)) {
702 r.z = 0.0f;
703 }
704 return r;
705}
706
707/* Triangle */
708
710 const ccl_private float3 &v2,
711 const ccl_private float3 &v3)
712{
713 return len(cross(v3 - v2, v1 - v2)) * 0.5f;
714}
715
716/* Orthonormal vectors */
717
721{
722#if 0
723 if (fabsf(N.y) >= 0.999f) {
724 *a = make_float3(1, 0, 0);
725 *b = make_float3(0, 0, 1);
726 return;
727 }
728 if (fabsf(N.z) >= 0.999f) {
729 *a = make_float3(1, 0, 0);
730 *b = make_float3(0, 1, 0);
731 return;
732 }
733#endif
734
735 if (N.x != N.y || N.x != N.z) {
736 *a = make_float3(N.z - N.y, N.x - N.z, N.y - N.x); //(1,1,1)x N
737 }
738 else {
739 *a = make_float3(N.z - N.y, N.x + N.z, -N.y - N.x); //(-1,1,1)x N
740 }
741
742 *a = normalize(*a);
743 *b = cross(N, *a);
744}
745
746/* Rotation of point around axis and angle */
747
749{
750 const float costheta = cosf(angle);
751 const float sintheta = sinf(angle);
752 float3 r;
753
754 r.x = ((costheta + (1 - costheta) * axis.x * axis.x) * p.x) +
755 (((1 - costheta) * axis.x * axis.y - axis.z * sintheta) * p.y) +
756 (((1 - costheta) * axis.x * axis.z + axis.y * sintheta) * p.z);
757
758 r.y = (((1 - costheta) * axis.x * axis.y + axis.z * sintheta) * p.x) +
759 ((costheta + (1 - costheta) * axis.y * axis.y) * p.y) +
760 (((1 - costheta) * axis.y * axis.z - axis.x * sintheta) * p.z);
761
762 r.z = (((1 - costheta) * axis.x * axis.z - axis.y * sintheta) * p.x) +
763 (((1 - costheta) * axis.y * axis.z + axis.x * sintheta) * p.y) +
764 ((costheta + (1 - costheta) * axis.z * axis.z) * p.z);
765
766 return r;
767}
768
769/* Calculate the angle between the two vectors a and b.
770 * The usual approach `acos(dot(a, b))` has severe precision issues for small angles,
771 * which are avoided by this method.
772 * Based on "Mangled Angles" from https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf
773 */
775{
776 return 2.0f * atan2f(len(a - b), len(a + b));
777}
778
779/* Tangent of the angle between vectors a and b. */
781{
782 return len(cross(a, b)) / dot(a, b);
783}
784
785/* projections */
787{
788 float len;
789 float u;
790 float v;
791 len = sqrtf(co.x * co.x + co.y * co.y);
792 if (len > 0.0f) {
793 u = (1.0f - (atan2f(co.x / len, co.y / len) / M_PI_F)) * 0.5f;
794 v = (co.z + 1.0f) * 0.5f;
795 }
796 else {
797 u = v = 0.0f;
798 }
799 return make_float2(u, v);
800}
801
803{
804 const float l = dot(co, co);
805 float u;
806 float v;
807 if (l > 0.0f) {
808 if (UNLIKELY(co.x == 0.0f && co.y == 0.0f)) {
809 u = 0.0f; /* Otherwise domain error. */
810 }
811 else {
812 u = (0.5f - atan2f(co.x, co.y) * M_1_2PI_F);
813 }
814 v = 1.0f - safe_acosf(co.z / sqrtf(l)) * M_1_PI_F;
815 }
816 else {
817 u = v = 0.0f;
818 }
819 return make_float2(u, v);
820}
821
823{
824 r[0] = val.x;
825 r[1] = val.y;
826 r[2] = val.z;
827}
828
830{
831#ifdef __KERNEL_METAL__
832 return as_type<uint3>(f);
833#else
835#endif
836}
837
839{
840#ifdef __KERNEL_METAL__
841 return as_type<float3>(f);
842#else
844#endif
845}
846
MINLINE float safe_acosf(float a)
MINLINE float safe_powf(float base, float exponent)
#define UNLIKELY(x)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
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
#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
#define exp
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
#define cos
VecBase< float, D > normalize(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
#define ceil
bool all(VecOp< bool, D >) RET
#define sqrt
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
VecBase< float, 4 > float4
VecBase< int, 3 > int3
VecBase< bool, 3 > bool3
VecBase< float, 3 > float3
MINLINE float compatible_signf(float f)
ccl_device_inline float len_squared(const float2 a)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ccl_device_inline float3 safe_normalize(const float3 a)
ccl_device_inline float3 reciprocal(const float3 a)
Definition math_float3.h:36
ccl_device_inline bool is_zero(const float3 a)
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 operator*(const float3 a, const float3 b)
Definition math_float3.h:57
ccl_device_inline bool isequal(const float3 a, const float3 b)
ccl_device_inline float3 power(const float3 v, const float e)
ccl_device_inline float3 safe_normalize_fallback(const float3 a, const float3 fallback)
ccl_device_inline float3 safe_fmod(const float3 a, const float3 b)
ccl_device_inline float3 compatible_sign(const float3 v)
ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)
ccl_device_inline int3 operator>=(const float3 a, const float3 b)
ccl_device_inline float3 one_float3()
Definition math_float3.h:26
ccl_device_inline float3 ensure_finite(const float3 v)
ccl_device_inline float3 normalize_len(const float3 a, ccl_private float *t)
ccl_device_inline float3 clamp(const float3 a, const float3 mn, const float3 mx)
ccl_device_inline float3 project(const float3 v, const float3 v_proj)
ccl_device_inline int3 operator<(const float3 a, const float3 b)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
ccl_device_template_spec float3 make_zero()
Definition math_float3.h:31
ccl_device_inline float3 safe_pow(const float3 a, const float3 b)
ccl_device_inline float3 operator/=(float3 &a, const float3 b)
ccl_device_inline float3 atan2(const float3 y, const float3 x)
ccl_device_inline float3 interp(const float3 a, const float3 b, const float t)
ccl_device_inline float dot_xy(const float3 a, const float3 b)
ccl_device_inline float3 fmod(const float3 a, const float b)
ccl_device_inline float3 fabs(const float3 a)
ccl_device_inline float reduce_add(const float3 a)
ccl_device_inline float3 rotate_around_axis(const float3 p, const float3 axis, const float angle)
ccl_device_inline auto isequal_mask(const float3 a, const float3 b)
ccl_device_inline float2 map_to_sphere(const float3 co)
ccl_device_inline bool isfinite_safe(const float3 v)
ccl_device_inline float3 mask(const MaskType mask, const float3 a)
ccl_device_inline float reduce_min(const float3 a)
ccl_device_inline float3 operator+(const float3 a, const float3 b)
ccl_device_inline float3 wrap(const float3 value, const float3 max, const float3 min)
ccl_device_inline auto is_zero_mask(const float3 a)
ccl_device_inline float average(const float3 a)
ccl_device_inline float3 safe_floored_fmod(const float3 a, const float3 b)
ccl_device_inline float2 map_to_tube(const float3 co)
ccl_device_inline bool any_zero(const float3 a)
ccl_device_inline float3 operator*=(float3 &a, const float3 b)
ccl_device_inline float3 operator/(const float f, const float3 a)
Definition math_float3.h:84
ccl_device_inline bool operator==(const float3 a, const float3 b)
ccl_device_inline float distance(const float3 a, const float3 b)
ccl_device_inline float3 uint3_as_float3(const uint3 f)
ccl_device_inline float3 safe_divide(const float3 a, const float3 b)
ccl_device_inline float triangle_area(const ccl_private float3 &v1, const ccl_private float3 &v2, const ccl_private float3 &v3)
ccl_device_inline float3 operator-(const float3 &a)
Definition math_float3.h:48
ccl_device_inline float reduce_max(const float3 a)
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 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 bool operator!=(const float3 a, const float3 b)
ccl_device_inline float3 operator+=(float3 &a, const float3 b)
ccl_device_inline float tan_angle(const float3 a, const float3 b)
ccl_device_inline float dot(const float3 a, const float3 b)
ccl_device_inline float len_squared(const float3 a)
ccl_device_inline float3 safe_sqrt(const float3 a)
ccl_device_inline float4 msub(const float4 a, const float4 b, const float4 c)
#define N
#define mix
#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:315
#define min(a, b)
Definition sort.cc:36
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
max
Definition text_draw.cc:251
uint len