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++) {
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>
295template<
typename T,
int Size>
300 for (
int i = 0;
i < Size;
i++) {
312template<
typename T,
int Size>
317 for (
int i = 0;
i < Size;
i++) {
325template<
typename T,
int Size>
335template<
typename T,
int Size>
345template<
typename T,
int Size>
351template<
typename T,
int Size>
357template<
typename T,
int Size>
363template<
typename T,
int Size>
373template<
typename T,
int Size>
383template<
typename T,
int Size>
387 for (
int i = 0;
i < Size;
i++) {
388 result[
i] = a[
i] >=
T(0) ? math ::sqrt(a[
i]) :
T(0);
406template<
typename T,
int Size>
412template<
typename T,
int Size>
424template<
typename T,
int Size>
428 for (
int i = 1;
i < Size;
i++) {
440 for (
int i = 1;
i < Size;
i++) {
467template<
typename T,
int Size>
473template<
typename T,
int Size>
479template<
typename T,
int Size>
485template<
typename T,
int Size>
490 return incident - 2.0 *
dot(normal, incident) * normal;
493template<
typename T,
int Size>
498 float dot_ni =
dot(normal, incident);
499 float k = 1.0f - eta * eta * (1.0f - dot_ni * dot_ni);
503 return eta * incident - (eta * dot_ni +
sqrt(k)) * normal;
510template<
typename T,
int Size>
517 return v_proj * (
dot(p, v_proj) /
dot(v_proj, v_proj));
520template<
typename T,
int Size>
526 constexpr T threshold = std::is_same_v<T, double> ? 1.0e-70 : 1.0e-35f;
527 if (out_length > threshold) {
528 out_length =
sqrt(out_length);
529 return v / out_length;
536template<
typename T,
int Size>
545 return a.x *
b.y - a.y *
b.x;
559 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};
568 return {
float(
double(a.y) *
double(
b.z) -
double(a.z) *
double(
b.y)),
569 float(
double(a.z) *
double(
b.x) -
double(a.x) *
double(
b.z)),
570 float(
double(a.x) *
double(
b.y) -
double(a.y) *
double(
b.x))};
581 int nv = int(poly.size());
588 for (
int i = 0;
i < nv;) {
589 n[0] = n[0] + ((*v_prev)[1] - (*v_curr)[1]) * ((*v_prev)[2] + (*v_curr)[2]);
590 n[1] = n[1] + ((*v_prev)[2] - (*v_curr)[2]) * ((*v_prev)[0] + (*v_curr)[0]);
591 n[2] = n[2] + ((*v_prev)[0] - (*v_curr)[0]) * ((*v_prev)[1] + (*v_curr)[1]);
630template<
typename T,
typename FactorT,
int Size>
635 return a * (1 - t) +
b * t;
641template<
typename T,
int Size>
645 return (a +
b) * 0.5;
651template<
typename T,
int Size>
665 return ((
b.x >
b.y) ? ((
b.x >
b.z) ? 0 : 2) : ((
b.y >
b.z) ? 1 : 2));
674 for (
int i = 1;
i < Size;
i++) {
688 for (
int i = 1;
i < Size;
i++) {
702 for (
int i = 1;
i < Size;
i++) {
714 for (
int i = 1;
i < Size;
i++) {
738 return {-
v.y -
v.z,
v.x,
v.x};
740 return {
v.y, -
v.x -
v.z,
v.y};
742 return {
v.z,
v.z, -
v.x -
v.y};
759template<
typename T,
int Size>
762 const T epsilon =
T(0))
764 for (
int i = 0;
i < Size;
i++) {
778template<
typename T,
int Size>
781 for (
int i = 0;
i < Size;
i++) {
794 for (
int i = 0;
i < Size;
i++) {
806template<
typename T,
int Size>
808 const T epsilon =
T(10) * std::numeric_limits<T>::epsilon())
826template<
typename T,
int Size>
#define BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC(op, a, b)
#define BLI_UNROLL_MATH_VEC_OP_VEC(op, a)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > normalize(VecOp< float, D >) RET
VecBase< T, D > faceforward(VecOp< T, D >, VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
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)
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)
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 > 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)
enum blender::math::isect_result::@263246371363174113064124076102177335155253321343 kind