48 return static_cast<T
>(.25) * (X[0] + X[1] + X[2] + X[3]);
56 for (
int32 i = 0; i < 4; i++)
58 Box.GrowToInclude(X[i]);
66 FMath::Min3((X[0] - X[1]).SizeSquared(), (X[1] - X[2]).SizeSquared(), (X[2] - X[0]).SizeSquared()),
67 FMath::Min3((X[0] - X[3]).SizeSquared(), (X[1] - X[3]).SizeSquared(), (X[2] - X[3]).SizeSquared()));
78 FMath::Max3((X[0] - X[1]).SizeSquared(), (X[1] - X[2]).SizeSquared(), (X[2] - X[0]).SizeSquared()),
79 FMath::Max3((X[0] - X[3]).SizeSquared(), (X[1] - X[3]).SizeSquared(), (X[2] - X[3]).SizeSquared()));
97 return TripleProduct(U, V, W) / 6;
104 for (
int32 i = 0; i < 4; i++)
112 (*MinAltitudeVertex) = 0;
115 for (
int32 i = 0; i < 4; i++)
122 (*MinAltitudeVertex) = i;
128 (*MinAltitudeVertex) = 4 - (*MinAltitudeVertex);
156 return TVec4<T>(W[0], W[1], W[2],
static_cast<T
>(1.0) - W[0] - W[1] - W[2]);
161 return Weights[0] * X[0] + Weights[1] * X[1] + Weights[2] * X[2] + Weights[3] * (
static_cast<T
>(1.0) - Weights[0] - Weights[1] - Weights[2]);
166 return Weights[0] * X[0] + Weights[1] * X[1] + Weights[2] * X[2] + Weights[3] * X[3];
172 return Weights[0] >= Tolerance && Weights[1] >= Tolerance && Weights[2] >= Tolerance && Weights[0]+Weights[1]+Weights[2] <= 1+Tolerance;
177 return FString::Printf(
TEXT(
"Tetrahedron: A: [%f, %f, %f], B: [%f, %f, %f], C: [%f, %f, %f], D: [%f, %f, %f]"),
178 X[0][0], X[0][1], X[0][2],
179 X[1][0], X[1][1], X[1][2],
180 X[2][0], X[2][1], X[2][2]);
243 T V1 = TripleProduct(
Location - X[0], X[1] - X[0], X[2] - X[0]);
244 T V2 = TripleProduct(X[3] - X[0], X[1] - X[0],
Location - X[0]);
245 T V3 = TripleProduct(X[3] - X[0],
Location - X[0], X[2] - X[0]);
247 return !(
fabs(V1) <= Tolerance ||
fabs(V2) <= Tolerance ||
fabs(V3) <= Tolerance ||
fabs(V4) <= Tolerance ||
282 for (
int32 i = 0; i < 4; i++)
326 const TTriangle<T> Tri(X[TriIndices[0]], X[TriIndices[1]], X[TriIndices[2]]);
360 for (
int32 EdgeIndex = 0; EdgeIndex < 6; ++EdgeIndex)
410 template <
typename T>
#define checkSlow(expr)
Definition AssertionMacros.h:332
@ INDEX_NONE
Definition CoreMiscDefines.h:150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
Definition ChaosArchive.h:167
static FORCEINLINE TAABB< T, d > EmptyAABB()
Definition AABB.h:623
Definition CorePlane.h:12
Definition Tetrahedron.h:18
T GetVolume() const
Definition Tetrahedron.h:87
bool Inside(const TVec3< T > &Location, const T HalfThickness=0) const
Definition Tetrahedron.h:205
TTetrahedron()
Definition Tetrahedron.h:20
TVec3< T > GetCenter() const
Definition Tetrahedron.h:46
static bool Outside(const TArray< TTriangle< T > > &Tris, const TVec3< T > &Location, const T HalfThickness=0)
Definition Tetrahedron.h:229
bool BarycentricInside(const TVec3< T > &Location, const T Tolerance=0) const
Definition Tetrahedron.h:169
T GetSignedVolume() const
Definition Tetrahedron.h:92
TVec4< T > GetBarycentricCoordinates(const TVec3< T > &Location) const
Definition Tetrahedron.h:153
bool RobustInside(const TVec3< T > &Location, const T Tolerance=0) const
Tolerance should be a small negative number to include boundary.
Definition Tetrahedron.h:241
T GetMaxEdgeLength() const
Definition Tetrahedron.h:82
bool Outside(const TVec3< T > &Location, const T HalfThickness=0) const
Definition Tetrahedron.h:223
TArray< TTriangle< T > > GetTriangles() const
Initialize outward facing triangles, regardless of the orientation of the tetrahedron.
Definition Tetrahedron.h:184
bool HasBoundingBox() const
Definition Tetrahedron.h:51
TAABB< T, 3 > BoundingBox() const
Definition Tetrahedron.h:52
TVec3< T > GetFirstThreeBarycentricCoordinates(const TVec3< T > &Location) const
Definition Tetrahedron.h:138
TVec3< T > GetPointFromBarycentricCoordinates(const TVec4< T > &Weights) const
Definition Tetrahedron.h:164
T GetAspectRatio() const
Definition Tetrahedron.h:133
TVec3< T > GetPointFromBarycentricCoordinates(const TVec3< T > &Weights) const
Definition Tetrahedron.h:159
FORCEINLINE const TVec3< T > & operator[](uint32 InIndex) const
Definition Tetrahedron.h:35
T GetMaxEdgeLengthSquared() const
Definition Tetrahedron.h:75
FORCEINLINE TVec3< T > & operator[](uint32 InIndex)
Definition Tetrahedron.h:29
T GetMinEdgeLengthSquared() const
Definition Tetrahedron.h:63
TTetrahedron(const TVec3< T > &In1, const TVec3< T > &In2, const TVec3< T > &In3, const TVec3< T > &In4)
Definition Tetrahedron.h:24
TVec3< T > ProjectToSurface(const TArray< TTriangle< T > > &Tris, const TVec3< T > &Location) const
Definition Tetrahedron.h:253
TAABB< T, 3 > GetBoundingBox() const
Definition Tetrahedron.h:53
TVec3< T > FindClosestPointAndBary(const TVec3< T > &Location, TVec4< T > &OutBary, const T Tolerance=0) const
Definition Tetrahedron.h:295
T GetMinimumAltitude(int32 *MinAltitudeVertex=nullptr) const
Definition Tetrahedron.h:100
static bool Inside(const TArray< TTriangle< T > > &Tris, const TVec3< T > &Location, const T HalfThickness=0)
Definition Tetrahedron.h:211
T GetMinEdgeLength() const
Definition Tetrahedron.h:70
void Invert()
Definition Tetrahedron.h:41
friend FChaosArchive & operator<<(FChaosArchive &Ar, TTetrahedron)
FString ToString() const
Definition Tetrahedron.h:175
FORCEINLINE TPlane< T, 3 > GetPlane() const
Definition Triangle.h:125
FORCEINLINE T PhiWithNormal(const TVec3< T > &InSamplePoint, TVec3< T > &OutNormal) const
Definition Triangle.h:245
void SetNumUninitialized(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2369
Definition SkeletalMeshComponent.h:307
TV RowMaj3x3RobustSolveLinearSystem(const T *A, const TV &b)
Definition Poisson.h:173
const TVector< T, d > FindClosestPointAndAlphaOnLineSegment(const TVector< T, d > &P0, const TVector< T, d > &P1, const TVector< T, d > &P, T &OutAlpha)
Definition Plane.h:130
FChaosArchive & operator<<(FChaosArchive &Ar, FRigidParticleControlFlags &Flags)
Definition RigidParticleControlFlags.cpp:15
TVector< T, 2 > ComputeBarycentricInPlane(const TVector< T, d > &P0, const TVector< T, d > &P1, const TVector< T, d > &P2, const TVector< T, d > &P)
Definition Plane.h:111
static constexpr UE_FORCEINLINE_HINT T Min3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:558
static constexpr UE_FORCEINLINE_HINT T Max3(const T A, const T B, const T C)
Definition UnrealMathUtility.h:551