5#include "MRPch/MRBindingMacros.h"
43 const Vector3i & d, std::int64_t rSq );
77 static_assert( std::is_floating_point_v<T> );
95 const T vv = v.lengthSq();
96 if ( uu > 4 * rSq || vv > 4 * rSq || ( v - u ).lengthSq() > 4 * rSq )
105 const T uv =
dot( u, v );
106 M = ( vv * ( uu - uv ) ) * u + ( uu * ( vv - uv ) ) * v;
109 E = 4 * rSq * W * W - M.lengthSq();
129 const auto q = d - a;
136 const T A = W * qq -
dot( q, M );
137 const T t =
dot( q, w );
140 if ( A < 0 && t >= 0 )
142 if ( A >= 0 && t <= 0 )
144 const T lhs = A * A * W;
145 const T rhs = E * t * t;
165class InSphereTester<int>
195 std::array<FastInt<192>, 3>
M;
325 if ( !tester.reset( a, b, c, rSq ) )
#define MRMESH_API
Definition MRMeshFwd.h:85
Definition MRInSphere.h:277
Definition MRFastInt.h:141
Definition MRInSphere.h:207
Definition MRInSphere.h:76
bool degenerateTriangle_
reset() got W == 0 with two coincident points and an existing perturbed sphere
Definition MRInSphere.h:270
bool reset(const Vector3i &a, const Vector3i &b, const Vector3i &c, std::int64_t rSq)
bool reset(const PreciseVertCoords &a, const PreciseVertCoords &b, const PreciseVertCoords &c, std::int64_t rSq)
void flip()
Definition MRInSphere.h:286
Vector3i64 pairV_
the fields are ordered by descending alignment to minimize the padding
Definition MRInSphere.h:266
Vector3i64 v
b - a, c - a
Definition MRInSphere.h:192
InSphereResult operator()(const PreciseVertCoords &d) const
Vector3i64 w
doubled normal of triangle abc, <= 2^63
Definition MRInSphere.h:193
InSphereResult operator()(const PreciseVertCoords &d) const
auto dot(const Matrix2< T > &a, const Matrix2< T > &b) -> decltype(dot(a.x, b.x))
double-dot product: x = a : b
Definition MRMatrix2.h:142
auto lengthSq() const -> decltype(std::declval< T >() *std::declval< T >())
Definition MRVector3.h:68
VertId vb_
Definition MRInSphere.h:268
bool outsideBothSpheres(const Vector3i &d) const
std::int64_t rSq
the squared radius of the sphere
Definition MRInSphere.h:197
Vector3i64 u
Definition MRInSphere.h:192
InSphereResult operator()(const Vector3i &d) const
bool reset(const PreciseVertCoords &a, const PreciseVertCoords &b, const PreciseVertCoords &c, std::int64_t rSq)
void flip()
Definition MRInSphere.h:179
bool reset(const Vector3< T > &va, const Vector3< T > &vb, const Vector3< T > &vc, T sqRadius)
Definition MRInSphere.h:84
std::array< FastInt< 192 >, 3 > M
2 * |w|^2 * ( circumcenter(abc) - a ), <= 2^161
Definition MRInSphere.h:195
MR_BIND_IGNORE const FastInt< 384 > & heightSq() const
Definition MRInSphere.h:262
InSphereResult operator()(const Vector3< T > &d) const
Definition MRInSphere.h:126
Vector3i pairPt_
the position of the coincident pair
Definition MRInSphere.h:267
void flip()
Definition MRInSphere.h:117
MR_BIND_TEMPLATE(std::pair< Vector3f, TriPointf > closestPointInTriangle(const Vector3f &p, const Vector3f &a, const Vector3f &b, const Vector3f &c))
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
FastInt< 192 > W
|w|^2, <= 2^128
Definition MRInSphere.h:194
VertId vc_
the ids of the sphere points given in reset()
Definition MRInSphere.h:268
VertId va_
Definition MRInSphere.h:268
Vector3i a
the first sphere point
Definition MRInSphere.h:191
MR_BIND_IGNORE const FastInt< 192 > & normalSq() const
squared length of normal()
Definition MRInSphere.h:257
bool degenerateTriangle() const
Definition MRInSphere.h:244
void flip()
Definition MRInSphere.h:222
MR_BIND_IGNORE const Vector3i64 & normal() const
doubled normal cross( b - a, c - a ) of the triangle, directed at the sphere's center
Definition MRInSphere.h:254
int pairSigma_
the side of the limit sphere's center: +1 along ( -Vy, Vx, 0 ), -1 the opposite
Definition MRInSphere.h:269
FastInt< 384 > E
sqr( 2 * h * |w|^2 ), h = distance from plane abc to the sphere's center, <= 2^322
Definition MRInSphere.h:196
InSphereTester< int > InSphereTesteri
Definition MRInSphere.h:202
InSphereTester< double > InSphereTesterd
Definition MRInSphere.h:201
InSphereTester< float > InSphereTesterf
Definition MRInSphere.h:200
InSphereResult inSphere(const Vector3i &a, const Vector3i &b, const Vector3i &c, const Vector3i &d, std::int64_t rSq)
InSphereResult
the result of inSphere predicates
Definition MRInSphere.h:22
@ NoSphere
Definition MRInSphere.h:25
@ Outside
the sphere exists, and the point D is strictly outside
Definition MRInSphere.h:27
@ Inside
the sphere exists, and the point D is strictly inside
Definition MRInSphere.h:33
@ OnSphere
Definition MRInSphere.h:31
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRPrecisePredicates3.h:37
auto cross(const Vector2< T > &a, const Vector2< T > &b) -> decltype(a.x *b.x)
cross product
Definition MRVector2.h:160
Definition MRVector3.h:33