3#include <Foundation/Math/Vec3.h>
4#include <Foundation/Math/Vec4.h>
19template <
typename Type>
24 PL_DECLARE_POD_TYPE();
26 using ComponentType = Type;
54#if PL_ENABLED(PL_MATH_CHECK_FOR_NAN)
55 void AssertNotNaN()
const
57 PL_ASSERT_ALWAYS(!
IsNaN(),
"This object contains NaN values. This can happen when you forgot to initialize it before using it. Please check that "
58 "all code-paths properly initialize this object.");
189template <
typename Type>
193template <
typename Type>
196#include <Foundation/Math/Implementation/Plane_inl.h>
An axis-aligned bounding box implementation.
Definition BoundingBox.h:12
An implementation of a bounding sphere.
Definition BoundingSphere.h:11
A 3x3 component matrix class.
Definition Mat3.h:9
A 4x4 component matrix class.
Definition Mat4.h:11
A 3-component vector class.
Definition Vec3.h:9
A 4-component vector class.
Definition Vec4.h:9
A class that represents a mathematical plane.
Definition Plane.h:21
bool IsValid() const
Checks whether the plane has valid values (not NaN, normalized normal).
Definition Plane_inl.h:223
static plPlaneTemplate< Type > MakeInvalid()
Returns an invalid plane with a zero normal.
Definition Plane_inl.h:17
static plPlaneTemplate< Type > MakeFromNormalAndPoint(const plVec3Template< Type > &vNormal, const plVec3Template< Type > &vPointOnPlane)
Creates a plane from a normal and a point on the plane.
Definition Plane_inl.h:26
bool IsNaN() const
Checks whether any component is NaN.
Definition Plane_inl.h:229
bool GetRayIntersection(const plVec3Template< Type > &vRayStartPos, const plVec3Template< Type > &vRayDir, Type *out_pIntersectionDinstance=nullptr, plVec3Template< Type > *out_pIntersection=nullptr) const
Returns true, if the ray hit the plane. The intersection time describes at which multiple of the ray ...
Definition Plane_inl.h:368
const plVec3Template< Type > Mirror(const plVec3Template< Type > &vPoint) const
Returns the mirrored point. E.g. on the other side of the plane, at the same distance.
Definition Plane_inl.h:173
const plVec3Template< Type > GetCoplanarDirection(const plVec3Template< Type > &vDirection) const
Take the given direction vector and returns a modified one that is coplanar to the plane.
Definition Plane_inl.h:179
bool FlipIfNecessary(const plVec3Template< Type > &vPoint, bool bPlaneShouldFacePoint=true)
Negates Normal/Distance to switch which side of the plane is front and back. Returns true,...
Definition Plane_inl.h:211
plPositionOnPlane::Enum GetObjectPosition(const plVec3Template< Type > *const pPoints, plUInt32 uiVertices) const
Returns on which side of the plane the set of points lies. Might be on both sides.
Definition Plane_inl.h:305
plResult SetFromDirections(const plVec3Template< Type > &vTangent1, const plVec3Template< Type > &vTangent2, const plVec3Template< Type > &vPointOnPlane)
Creates a plane from two direction vectors that span the plane, and one point on it.
Definition Plane_inl.h:73
Type GetDistanceTo(const plVec3Template< Type > &vPoint) const
Returns the distance of the point to the plane.
Definition Plane_inl.h:141
Type GetMaximumDistanceTo(const plBoundingBoxTemplate< Type > &box) const
Returns the maximum distance between given box and a plane.
Definition AllClasses_inl.h:165
bool GetLineSegmentIntersection(const plVec3Template< Type > &vLineStartPos, const plVec3Template< Type > &vLineEndPos, Type *out_pHitFraction=nullptr, plVec3Template< Type > *out_pIntersection=nullptr) const
Returns true, if there is any intersection with the plane between the line's start and end position....
Definition Plane_inl.h:417
plResult SetFromPoints(const plVec3Template< Type > &v1, const plVec3Template< Type > &v2, const plVec3Template< Type > &v3)
Creates the plane-equation from three points on the plane.
Definition Plane_inl.h:53
static plResult FindSupportPoints(const plVec3Template< Type > *const pVertices, plInt32 iMaxVertices, plInt32 &out_i1, plInt32 &out_i2, plInt32 &out_i3)
Returns three points from an unreliable set of points, that reliably form a plane....
Definition Plane_inl.h:259
bool IsIdentical(const plPlaneTemplate< Type > &rhs) const
Checks whether this plane and the other are identical.
Definition Plane_inl.h:187
static plResult GetPlanesIntersectionPoint(const plPlaneTemplate< Type > &p0, const plPlaneTemplate< Type > &p1, const plPlaneTemplate< Type > &p2, plVec3Template< Type > &out_vResult)
Computes the one point where all three planes intersect. Returns PL_FAILURE if no such point exists.
Definition Plane_inl.h:478
static plPlaneTemplate< Type > MakeFromPoints(const plVec3Template< Type > &v1, const plVec3Template< Type > &v2, const plVec3Template< Type > &v3)
Creates a plane from three points.
Definition Plane_inl.h:37
void GetMinMaxDistanceTo(Type &out_fMin, Type &out_fMax, const plVec3Template< Type > *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plVec3Template< Type >)) const
Returns the minimum and maximum distance that any of the given points had to the plane.
Definition Plane_inl.h:452
plPlaneTemplate()
Default constructor. Does not initialize the plane.
Definition Plane_inl.h:6
void Flip()
Negates Normal/Distance to switch which side of the plane is front and back.
Definition Plane_inl.h:134
bool IsFinite() const
Checks whether any component is Infinity.
Definition Plane_inl.h:235
const plVec3Template< Type > ProjectOntoPlane(const plVec3Template< Type > &vPoint) const
Projects a point onto a plane (along the planes normal).
Definition Plane_inl.h:167
plPositionOnPlane::Enum GetPointPosition(const plVec3Template< Type > &vPoint) const
Returns on which side of the plane the point lies.
Definition Plane_inl.h:147
Type GetMinimumDistanceTo(const plVec3Template< Type > *pPoints, plUInt32 uiNumPoints, plUInt32 uiStride=sizeof(plVec3Template< Type >)) const
Returns the minimum distance that any of the given points had to the plane.
Definition Plane_inl.h:431
void Transform(const plMat3Template< Type > &m)
Transforms the plane with the given matrix.
Definition Plane_inl.h:84
bool IsEqual(const plPlaneTemplate< Type > &rhs, Type fEpsilon=plMath::DefaultEpsilon< Type >()) const
Checks whether this plane and the other are equal within some threshold.
Definition Plane_inl.h:193
bool GetRayIntersectionBiDirectional(const plVec3Template< Type > &vRayStartPos, const plVec3Template< Type > &vRayDir, Type *out_pIntersectionDistance=nullptr, plVec3Template< Type > *out_pIntersection=nullptr) const
Returns true, if the ray intersects the plane. Intersection time and point are stored in the out-para...
Definition Plane_inl.h:394
plVec4Template< Type > GetAsVec4() const
Returns an plVec4 with the plane normal in x,y,z and the negative distance in w.
Definition Plane_inl.h:47
Describes on which side of a plane a point or an object is located.
Definition Plane.h:8
Enum
Definition Plane.h:10
@ Spanning
Something is spanning a plane, i.e. some points are on the front and some on the back.
Definition Plane.h:14
@ Back
Something is completely on the back side of a plane.
Definition Plane.h:11
@ OnPlane
Something is lying completely on a plane (all points)
Definition Plane.h:13
@ Front
Something is completely in front of a plane.
Definition Plane.h:12
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54