![]() |
Plasma Engine
2.0
|
A class that represents a mathematical plane. More...
#include <Plane.h>
Public Types | |
using | ComponentType = Type |
Public Member Functions | |
PL_DECLARE_POD_TYPE () | |
plPlaneTemplate () | |
Default constructor. Does not initialize the plane. | |
plVec4Template< Type > | GetAsVec4 () const |
Returns an plVec4 with the plane normal in x,y,z and the negative distance in w. | |
plResult | SetFromPoints (const plVec3Template< Type > &v1, const plVec3Template< Type > &v2, const plVec3Template< Type > &v3) |
Creates the plane-equation from three points on the plane. | |
plResult | SetFromPoints (const plVec3Template< Type > *const pVertices) |
Creates the plane-equation from three points on the plane, given as an array. | |
plResult | SetFromPoints (const plVec3Template< Type > *const pVertices, plUInt32 uiMaxVertices) |
Creates the plane-equation from a set of unreliable points lying on the same plane. Some points might be equal or too close to each other for the typical algorithm. Returns false, if no reliable set of points could be found. Does try to create a plane anyway. | |
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. | |
Type | GetDistanceTo (const plVec3Template< Type > &vPoint) const |
Returns the distance of the point to the plane. | |
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. | |
Type | GetMinimumDistanceTo (const plBoundingBoxTemplate< Type > &box) const |
Returns the minimum distance between given box and a plane. | |
Type | GetMaximumDistanceTo (const plBoundingBoxTemplate< Type > &box) const |
Returns the maximum distance between given box and a plane. | |
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. | |
plPositionOnPlane::Enum | GetPointPosition (const plVec3Template< Type > &vPoint) const |
Returns on which side of the plane the point lies. | |
plPositionOnPlane::Enum | GetPointPosition (const plVec3Template< Type > &vPoint, Type fPlaneHalfWidth) const |
Returns on which side of the plane the point lies. | |
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. | |
plPositionOnPlane::Enum | GetObjectPosition (const plVec3Template< Type > *const pPoints, plUInt32 uiVertices, Type fPlaneHalfWidth) const |
Returns on which side of the plane the set of points lies. Might be on both sides. | |
plPositionOnPlane::Enum | GetObjectPosition (const plBoundingSphereTemplate< Type > &sphere) const |
Returns on which side of the plane the sphere is located. | |
plPositionOnPlane::Enum | GetObjectPosition (const plBoundingBoxTemplate< Type > &box) const |
Returns on which side of the plane the box is located. | |
const plVec3Template< Type > | ProjectOntoPlane (const plVec3Template< Type > &vPoint) const |
Projects a point onto a plane (along the planes normal). | |
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. | |
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. | |
bool | IsIdentical (const plPlaneTemplate< Type > &rhs) const |
Checks whether this plane and the other are identical. | |
bool | IsEqual (const plPlaneTemplate< Type > &rhs, Type fEpsilon=plMath::DefaultEpsilon< Type >()) const |
Checks whether this plane and the other are equal within some threshold. | |
bool | IsValid () const |
Checks whether the plane has valid values (not NaN, normalized normal). | |
bool | IsNaN () const |
Checks whether any component is NaN. | |
bool | IsFinite () const |
Checks whether any component is Infinity. | |
void | Transform (const plMat3Template< Type > &m) |
Transforms the plane with the given matrix. | |
void | Transform (const plMat4Template< Type > &m) |
Transforms the plane with the given matrix. | |
void | Flip () |
Negates Normal/Distance to switch which side of the plane is front and back. | |
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, if the plane had to be flipped. | |
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 direction the ray hit the plane. | |
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-parameters. Allows for intersections at negative times (shooting into the opposite direction). | |
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. Returns the fraction along the line and the actual intersection point. | |
Static Public Member Functions | |
static plPlaneTemplate< Type > | MakeInvalid () |
Returns an invalid plane with a zero normal. | |
static plPlaneTemplate< Type > | MakeFromNormalAndPoint (const plVec3Template< Type > &vNormal, const plVec3Template< Type > &vPointOnPlane) |
Creates a plane from a normal and a point on the plane. | |
static plPlaneTemplate< Type > | MakeFromPoints (const plVec3Template< Type > &v1, const plVec3Template< Type > &v2, const plVec3Template< Type > &v3) |
Creates a plane from three points. | |
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. | |
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. Returns false, if there are none. | |
Public Attributes | |
plVec3Template< Type > | m_vNormal |
Type | m_fNegDistance |
A class that represents a mathematical plane.
Type plPlaneTemplate< 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.
'Minimum' means the (non-absolute) distance of a point to the plane. So a point behind the plane will always have a 'lower distance' than a point in front of the plane, even if that is closer to the plane's surface.
void plPlaneTemplate< Type >::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.
'Minimum' (and 'maximum') means the (non-absolute) distance of a point to the plane. So a point behind the plane will always have a 'lower distance' than a point in front of the plane, even if that is closer to the plane's surface.
|
nodiscard |
Returns true, if the ray hit the plane. The intersection time describes at which multiple of the ray direction the ray hit the plane.
An intersection will be reported regardless of whether the ray starts 'behind' or 'in front of' the plane, as long as it points at it. vRayDir does not need to be normalized.
out_vIntersection = vRayStartPos + out_fIntersection * vRayDir
Intersections with out_fIntersection less than zero will be discarded and not reported as intersections. If such intersections are desired, use GetRayIntersectionBiDirectional instead.
|
staticnodiscard |
Creates a plane from a normal and a point on the plane.
|
staticnodiscard |
Creates a plane from three points.
plResult plPlaneTemplate< Type >::SetFromPoints | ( | const plVec3Template< Type > *const | pVertices, |
plUInt32 | uiMaxVertices ) |
Creates the plane-equation from a set of unreliable points lying on the same plane. Some points might be equal or too close to each other for the typical algorithm. Returns false, if no reliable set of points could be found. Does try to create a plane anyway.
The given vertices can be partially equal or lie on the same line. The algorithm will try to find 3 vertices, that form a plane, and deduce the normal from them. This algorithm is much slower, than all the other methods, so only use it, when you know, that your data can contain such configurations.