63 return (c > std::numeric_limits<T>::epsilon()) ? (
dot(a,
b) / c) :
T(0);
96 return co.x * plane.x + co.y * plane.y + co.z * plane.z + plane.w;
109template<
typename T,
int Size>
116 if (len_sq ==
T(0)) {
119 const T lambda =
dot(p - l1, d) / len_sq;
120 if (lambda <=
T(0)) {
123 if (lambda >=
T(1)) {
126 return l1 + lambda * d;
133template<
typename T,
int Size>
151 return pt - (
dot(n, pt) + plane.w) * n;
167 return pt - (side / len_sq) * n;
181 const T fac = side / len_sq;
182 return len_sq * (fac * fac);
198template<
typename T,
int Size>
205 if (len_sq ==
T(0)) {
208 return dot(p - l1, d) / len_sq;
292 const T s1 =
cross(
v2 - v1, pt - v1);
294 const T s3 =
cross(v1 - v3, pt - v3);
295 if (s1 >=
T(0) && s2 >=
T(0) && s3 >=
T(0)) {
298 if (s1 <=
T(0) && s2 <=
T(0) && s3 <=
T(0)) {
319 const T s1 =
cross(
v2 - v1, p - v1);
321 const T s3 =
cross(v4 - v3, p - v3);
322 const T s4 =
cross(v1 - v4, p - v4);
323 if (s1 >=
T(0) && s2 >=
T(0) && s3 >=
T(0) && s4 >=
T(0)) {
326 if (s1 <=
T(0) && s2 <=
T(0) && s3 <=
T(0) && s4 <=
T(0)) {
342 pt,
reinterpret_cast<const float (*)[2]
>(verts.
data()),
uint(verts.
size()));
384 return corner_count - (poly_count * 2);
410 const_cast<float (*)[2]
>(
reinterpret_cast<const float (*)[2]
>(verts.
data())),
445 return v0 * ((
T(1) - u) * (
T(1) -
v)) + v1 * (u * (
T(1) -
v)) +
v2 * (u *
v) +
446 v3 * ((
T(1) - u) *
v);
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
constexpr int64_t size() const
constexpr T * data() const
constexpr const T * data() const
constexpr int64_t size() const
int isect_point_tri(const VecBase< T, 2 > &pt, const VecBase< T, 2 > &v1, const VecBase< T, 2 > &v2, const VecBase< T, 2 > &v3)
int isect_point_quad(const VecBase< T, 2 > &p, const VecBase< T, 2 > &v1, const VecBase< T, 2 > &v2, const VecBase< T, 2 > &v3, const VecBase< T, 2 > &v4)
T length_squared(const VecBase< T, Size > &a)
T cotangent_tri_weight(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
float3x3 axis_dominant_to_m3(const float3 &normal)
T dist_squared_to_line_segment(const VecBase< T, Size > &p, const VecBase< T, Size > &l1, const VecBase< T, Size > &l2)
VecBase< T, Size > closest_to_line_segment(const VecBase< T, Size > &p, const VecBase< T, Size > &l1, const VecBase< T, Size > &l2)
VecBase< T, 3 > interp_bilinear_quad(const VecBase< T, 3 > &v0, const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3, const T u, const T v)
T dist_squared_to_plane(const VecBase< T, 3 > &p, const VecBase< T, 4 > &plane)
float2 map_to_sphere(const float3 &co)
T plane_point_side(const VecBase< T, 4 > &plane, const VecBase< T, 3 > &co)
std::optional< float3 > isect_line_plane(const float3 &l1, const float3 &l2, const float3 &plane_co, const float3 &plane_no)
T length(const VecBase< T, Size > &a)
constexpr int poly_to_tri_count(const int poly_count, const int corner_count)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
T area_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
VecBase< T, 3 > closest_to_plane_normalized(const VecBase< T, 4 > &plane, const VecBase< T, 3 > &pt)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > normal_quad(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3, const VecBase< T, 3 > &v4)
float3 barycentric_weights(const float2 &v1, const float2 &v2, const float2 &v3, const float2 &co)
float area_poly(Span< float2 > verts)
int isect_line_line(const float3 &v1, const float3 &v2, const float3 &v3, const float3 &v4, float3 &r_i1, float3 &r_i2)
VecBase< T, 4 > plane_from_point_normal(const VecBase< T, 3 > &co, const VecBase< T, 3 > &no)
T line_point_factor(const VecBase< T, Size > &p, const VecBase< T, Size > &l1, const VecBase< T, Size > &l2)
VecBase< T, 3 > closest_to_plane(const VecBase< T, 4 > &plane, const VecBase< T, 3 > &pt)
void interp_weights_poly(MutableSpan< float > r_weights, Span< float2 > verts, const float2 &co)
bool isect_point_poly(const float2 &pt, Span< float2 > verts)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
float area_poly_v2(const float verts[][2], unsigned int nr)
VecBase< float, 2 > float2
bool isect_point_poly_v2(const float pt[2], const float verts[][2], unsigned int nr)
MatBase< float, 3, 3 > float3x3
void interp_weights_poly_v2(float w[], float v[][2], int n, const float co[2])
bool isect_line_plane_v3(float r_isect_co[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3]) ATTR_WARN_UNUSED_RESULT
ATTR_WARN_UNUSED_RESULT const BMVert * v2
VecBase< float, 3 > float3
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3])