CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Math::TPlane< T > Struct Template Reference

A plane represented by a normal and a distance. More...

#include <CeresEngine/Math/Geometry.hpp>

Public Types

enum  Side : UInt32 { None = 0U , Positive = (1U << 0U) , Negative = (1U << 1U) , Both = Positive | Negative }
 The "positive side" of the plane is the half space to which the plane normal points. More...
 

Public Member Functions

 TPlane ()=default
 
 TPlane (const TPlane &)=default
 
 TPlane (const TVector3< T > &normal, T d)
 
 TPlane (const TVector4< T > &data)
 
 TPlane (T a, T b, T c, T d)
 
 TPlane (const TVector3< T > &normal, const TVector3< T > &point)
 
 TPlane (const TVector3< T > &point0, const TVector3< T > &point1, const TVector3< T > &point2)
 
TPlaneoperator= (const TPlane &rhs)=default
 
void transform (const TMatrix4< T > &matrix)
 Transforms the plane by the given matrix.
 
void transform (const TTransform< T > &aTransform)
 Transforms the plane by the given matrix.
 
Side getSide (const TVector3< T > &point, T epsilon=0.0) const
 Returns the side of the plane where the point is located on.
 
Side getSide (const TAABox< T > &box) const
 Returns the side where the alignedBox is.
 
Side getSide (const TSphere< T > &sphere) const
 Returns the side where the sphere is.
 
getDistance (const TVector3< T > &point) const
 Returns a distance from point to plane.
 
TVector3< T > projectVector (const TVector3< T > &v) const
 Project a vector onto the plane.
 
normalize ()
 Normalizes the plane's normal and the length scale of d.
 
bool intersects (const TAABox< T > &box) const
 Box/plane intersection.
 
bool intersects (const TSphere< T > &sphere) const
 Sphere/plane intersection.
 
TRayIntersection< T > intersects (const TRay< T > &ray) const
 Ray/plane intersection, returns boolean result and distance to intersection point.
 
bool operator== (const TPlane &rhs) const
 
bool operator!= (const TPlane &rhs) const
 

Public Attributes

TVector3< T > normal = TVector3<T>(T(0.0))
 
distance = T(0.0)
 

Detailed Description

template<typename T>
struct Math::TPlane< T >

A plane represented by a normal and a distance.

Member Enumeration Documentation

◆ Side

template<typename T >
enum Math::TPlane::Side : UInt32

The "positive side" of the plane is the half space to which the plane normal points.

The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Enumerator
None 
Positive 
Negative 
Both 

Constructor & Destructor Documentation

◆ TPlane() [1/7]

template<typename T >
Math::TPlane< T >::TPlane ( )
default

◆ TPlane() [2/7]

template<typename T >
Math::TPlane< T >::TPlane ( const TPlane< T > &  )
default

◆ TPlane() [3/7]

template<typename T >
Math::TPlane< T >::TPlane ( const TVector3< T > &  normal,
d 
)
inline

◆ TPlane() [4/7]

template<typename T >
Math::TPlane< T >::TPlane ( const TVector4< T > &  data)
inlineexplicit

◆ TPlane() [5/7]

template<typename T >
Math::TPlane< T >::TPlane ( a,
b,
c,
d 
)
inline

◆ TPlane() [6/7]

template<typename T >
Math::TPlane< T >::TPlane ( const TVector3< T > &  normal,
const TVector3< T > &  point 
)
inline

◆ TPlane() [7/7]

template<typename T >
Math::TPlane< T >::TPlane ( const TVector3< T > &  point0,
const TVector3< T > &  point1,
const TVector3< T > &  point2 
)

Member Function Documentation

◆ getDistance()

template<typename T >
T Math::TPlane< T >::getDistance ( const TVector3< T > &  point) const

Returns a distance from point to plane.

Note
The sign of the return value is positive if the point is on the positive side of the plane, negative if the point is on the negative side, and zero if the point is on the plane.

◆ getSide() [1/3]

template<typename T >
Side Math::TPlane< T >::getSide ( const TAABox< T > &  box) const

Returns the side where the alignedBox is.

The flag both indicates an intersecting box. One corner ON the plane is sufficient to consider the box and the plane intersecting.

◆ getSide() [2/3]

template<typename T >
Side Math::TPlane< T >::getSide ( const TSphere< T > &  sphere) const

Returns the side where the sphere is.

The flag BOTH_SIDE indicates an intersecting sphere.

◆ getSide() [3/3]

template<typename T >
Side Math::TPlane< T >::getSide ( const TVector3< T > &  point,
epsilon = 0.0 
) const

Returns the side of the plane where the point is located on.

Note
NO_SIDE signifies the point is on the plane.

◆ intersects() [1/3]

template<typename T >
bool Math::TPlane< T >::intersects ( const TAABox< T > &  box) const

Box/plane intersection.

◆ intersects() [2/3]

template<typename T >
TRayIntersection< T > Math::TPlane< T >::intersects ( const TRay< T > &  ray) const

Ray/plane intersection, returns boolean result and distance to intersection point.

◆ intersects() [3/3]

template<typename T >
bool Math::TPlane< T >::intersects ( const TSphere< T > &  sphere) const

Sphere/plane intersection.

◆ normalize()

template<typename T >
T Math::TPlane< T >::normalize ( )

Normalizes the plane's normal and the length scale of d.

◆ operator!=()

template<typename T >
bool Math::TPlane< T >::operator!= ( const TPlane< T > &  rhs) const
inline

◆ operator=()

template<typename T >
TPlane & Math::TPlane< T >::operator= ( const TPlane< T > &  rhs)
default

◆ operator==()

template<typename T >
bool Math::TPlane< T >::operator== ( const TPlane< T > &  rhs) const
inline

◆ projectVector()

template<typename T >
TVector3< T > Math::TPlane< T >::projectVector ( const TVector3< T > &  v) const

Project a vector onto the plane.

◆ transform() [1/2]

template<typename T >
void Math::TPlane< T >::transform ( const TMatrix4< T > &  matrix)

Transforms the plane by the given matrix.

◆ transform() [2/2]

template<typename T >
void Math::TPlane< T >::transform ( const TTransform< T > &  aTransform)
inline

Transforms the plane by the given matrix.

Member Data Documentation

◆ distance

template<typename T >
T Math::TPlane< T >::distance = T(0.0)

◆ normal

template<typename T >
TVector3<T> Math::TPlane< T >::normal = TVector3<T>(T(0.0))

The documentation for this struct was generated from the following file: