24template<
typename T,
int Size>
27 const T &epsilon_factor)
29 for (
int i = 0; i < Size; i++) {
30 const float epsilon = epsilon_factor *
math::abs(a[i]);
41 for (
int i = 0; i < Size; i++) {
42 result[i] = a[i] >= 0 ? a[i] : -a[i];
50template<
typename T,
int Size>
56template<
typename T,
int Size>
65template<
typename T,
int Size>
81template<
typename T,
int Size>
87template<
typename T,
int Size>
96template<
typename T,
int Size>
112template<
typename T,
int Size>
118template<
typename T,
int Size>
124 for (
int i = 0; i < Size; i++) {
130template<
typename T,
int Size>
134 for (
int i = 0; i < Size; i++) {
140template<
typename T,
int Size>
147template<
typename T,
int Size>
151 for (
int i = 0; i < Size; i++) {
157template<
typename T,
int Size>
163template<
typename T,
int Size>
168 for (
int i = 0; i < Size; i++) {
177template<
typename T,
int Size>
187template<
typename T,
int Size>
194 for (
int i = 0; i < Size; i++) {
200template<
typename T,
int Size>
205 for (
int i = 0; i < Size; i++) {
212template<
typename T,
int Size>
217 for (
int i = 0; i < Size; i++) {
227template<
typename T,
int Size>
231 for (
int i = 0; i < Size; i++) {
241template<
typename T,
int Size>
245 for (
int i = 0; i < Size; i++) {
255template<
typename T,
int Size>
261 for (
int i = 0; i < Size; i++) {
271template<
typename T,
int Size>
278template<
typename T,
int Size>
301template<
typename T,
int Size>
306 for (
int i = 0; i < Size; i++) {
309 result[i] = ((a[i] +
b[i] - 1) /
b[i]) *
b[i];
318template<
typename T,
int Size>
323 for (
int i = 0; i < Size; i++) {
326 result[i] = (a[i] +
b[i] - 1) /
b[i];
331template<
typename T,
int Size>
341template<
typename T,
int Size>
351template<
typename T,
int Size>
357template<
typename T,
int Size>
363template<
typename T,
int Size>
369template<
typename T,
int Size>
379template<
typename T,
int Size>
389template<
typename T,
int Size>
393 for (
int i = 0; i < Size; i++) {
394 result[i] = a[i] >=
T(0) ? math ::sqrt(a[i]) :
T(0);
412template<
typename T,
int Size>
418template<
typename T,
int Size>
430template<
typename T,
int Size>
434 for (
int i = 1; i < Size; i++) {
446 for (
int i = 1; i < Size; i++) {
473template<
typename T,
int Size>
479template<
typename T,
int Size>
485template<
typename T,
int Size>
491template<
typename T,
int Size>
496 return incident - 2.0 *
dot(normal, incident) * normal;
499template<
typename T,
int Size>
504 float dot_ni =
dot(normal, incident);
505 float k = 1.0f - eta * eta * (1.0f - dot_ni * dot_ni);
509 return eta * incident - (eta * dot_ni +
sqrt(k)) * normal;
516template<
typename T,
int Size>
520 if (
is_zero(v_proj)) [[unlikely]] {
523 return v_proj * (
dot(p, v_proj) /
dot(v_proj, v_proj));
526template<
typename T,
int Size>
532 constexpr T threshold = std::is_same_v<T, double> ? 1.0e-70 : 1.0e-35f;
533 if (out_length > threshold) {
534 out_length =
sqrt(out_length);
535 return v / out_length;
542template<
typename T,
int Size>
551 return a.x *
b.y - a.y *
b.x;
565 return {a.y *
b.z - a.z *
b.y, a.z *
b.x - a.x *
b.z, a.x *
b.y - a.y *
b.x};
574 return {
float(
double(a.y) *
double(
b.z) -
double(a.z) *
double(
b.y)),
575 float(
double(a.z) *
double(
b.x) -
double(a.x) *
double(
b.z)),
576 float(
double(a.x) *
double(
b.y) -
double(a.y) *
double(
b.x))};
587 int nv = int(poly.size());
594 for (
int i = 0; i < nv;) {
595 n[0] = n[0] + ((*v_prev)[1] - (*v_curr)[1]) * ((*v_prev)[2] + (*v_curr)[2]);
596 n[1] = n[1] + ((*v_prev)[2] - (*v_curr)[2]) * ((*v_prev)[0] + (*v_curr)[0]);
597 n[2] = n[2] + ((*v_prev)[0] - (*v_curr)[0]) * ((*v_prev)[1] + (*v_curr)[1]);
636template<
typename T,
typename FactorT,
int Size>
641 return a * (1 - t) +
b * t;
647template<
typename T,
int Size>
651 return (a +
b) * 0.5;
657template<
typename T,
int Size>
662 return (
dot(reference, incident) < 0) ? vector : -vector;
671 return ((
b.x >
b.y) ? ((
b.x >
b.z) ? 0 : 2) : ((
b.y >
b.z) ? 1 : 2));
680 for (
int i = 1; i < Size; i++) {
694 for (
int i = 1; i < Size; i++) {
708 for (
int i = 1; i < Size; i++) {
720 for (
int i = 1; i < Size; i++) {
744 return {-
v.y -
v.z,
v.x,
v.x};
746 return {
v.y, -
v.x -
v.z,
v.y};
748 return {
v.z,
v.z, -
v.x -
v.y};
765template<
typename T,
int Size>
768 const T epsilon =
T(0))
770 for (
int i = 0; i < Size; i++) {
784template<
typename T,
int Size>
787 for (
int i = 0; i < Size; i++) {
800 for (
int i = 0; i < Size; i++) {
812template<
typename T,
int Size>
814 const T epsilon =
T(10) * std::numeric_limits<T>::epsilon())
832template<
typename T,
int Size>
#define BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC(op, a, b)
#define BLI_UNROLL_MATH_VEC_OP_VEC(op, a)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
T length_squared(const VecBase< T, Size > &a)
VecBase< T, 3 > normal_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
T pow(const T &x, const T &power)
T clamp(const T &a, const T &min, const T &max)
bool is_any_zero(const T &a)
T safe_divide(const T &a, const T &b)
VecBase< T, Size > project(const VecBase< T, Size > &p, const VecBase< T, Size > &v_proj)
T reduce_max(const VecBase< T, Size > &a)
isect_result< VecBase< T, Size > > isect_seg_seg(const VecBase< T, Size > &v1, const VecBase< T, Size > &v2, const VecBase< T, Size > &v3, const VecBase< T, Size > &v4)
T distance(const T &a, const T &b)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T length(const VecBase< T, Size > &a)
T floored_mod(const T &a, const T &b)
VecBase< float, 3 > cross_high_precision(const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
QuaternionBase< T > normalize_and_get_length(const QuaternionBase< T > &q, T &out_length)
bool is_unit_scale(const MatBase< T, NumCol, NumRow > &m)
T length_manhattan(const VecBase< T, Size > &a)
T reduce_min(const VecBase< T, Size > &a)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
T average(const VecBase< T, Size > &a)
T min(const T &a, const T &b)
T step(const T &edge, const T &value)
T midpoint(const T &a, const T &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
T safe_mod(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T safe_pow(const T &x, const T &power)
T fallback_pow(const T &x, const T &power, const T &fallback)
VecBase< T, 3 > cross_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
void min_max(const T &value, T &min, T &max)
T reduce_mul(const VecBase< T, Size > &a)
VecBase< T, Size > refract(const VecBase< T, Size > &incident, const VecBase< T, Size > &normal, const T &eta)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, Size > faceforward(const VecBase< T, Size > &vector, const VecBase< T, Size > &incident, const VecBase< T, Size > &reference)
bool almost_equal_relative(const VecBase< T, Size > &a, const VecBase< T, Size > &b, const T &epsilon_factor)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T distance_manhattan(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool is_equal(const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
VecBase< T, 3 > orthogonal(const VecBase< T, 3 > &v)
int dominant_axis(const VecBase< T, 3 > &a)
VecBase< T, Size > reflect(const VecBase< T, Size > &incident, const VecBase< T, Size > &normal)
VecBase< T, Size > ceil_to_multiple(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T max(const T &a, const T &b)
T mod(const T &a, const T &b)
bool is_unit(const VecBase< T, Size > &a, const T epsilon=T(10) *std::numeric_limits< T >::epsilon())
VecBase< T, 3 > cross_poly(Span< VecBase< T, 3 > > poly)
T reduce_add(const VecBase< T, Size > &a)
VecBase< T, Size > safe_sqrt(const VecBase< T, Size > &a)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ATTR_WARN_UNUSED_RESULT const BMVert * v
ATTR_WARN_UNUSED_RESULT const BMVert * v2
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
enum blender::math::isect_result::@350007376102037237011032121035000216373245041345 kind