3es  0.7
tes::planegeom Namespace Reference

Plane geometry functions. More...

Enumerations

enum  PlaneClassification { PC_Behind = -1, PC_On = 0, PC_InFront = 1 }
 Point classification results. More...
 

Functions

template<typename T >
Vector4< T > create (const Vector3< T > &normal, T distance)
 Create a plane from a normal and distance (D) value. More...
 
template<typename T >
Vector4< T > fromNormalAndPoint (const Vector3< T > &normal, const Vector3< T > &pointOnPlane)
 Create a plane from a normal and a point on the plane. More...
 
template<typename T >
signedDistanceToPoint (const Vector4< T > &plane, const Vector3< T > &point)
 Calculate the signed distance between the plane and point. More...
 
template<typename T >
Vector3< T > projectPoint (const Vector4< T > &plane, const Vector3< T > &point)
 Project a point onto a plane. More...
 
template<typename T >
int classifyPoint (const Vector4< T > &plane, const Vector3< T > &point, T epsilon=0)
 Classify a point with respect to a plane (see PlaneClassification). More...
 

Detailed Description

Plane geometry functions.

A plane is defined by a Vector4 where the xyz components are the normal and the w component is the plane distance.

Enumeration Type Documentation

◆ PlaneClassification

Point classification results.

Enumerator
PC_Behind 

Behind the plane.

PC_On 

On or part of the plane.

PC_InFront 

In front of the plane.

Function Documentation

◆ classifyPoint()

template<typename T >
int tes::planegeom::classifyPoint ( const Vector4< T > &  plane,
const Vector3< T > &  point,
epsilon = 0 
)
inline

Classify a point with respect to a plane (see PlaneClassification).

Parameters
planeThe plane equation.
pointThe point of interest.
epsilonEpsilon value used as a tolerance for PC_On results.
Returns
The point's PlaneClassification.

References PC_Behind, PC_InFront, PC_On, and signedDistanceToPoint().

◆ create()

template<typename T >
Vector4<T> tes::planegeom::create ( const Vector3< T > &  normal,
distance 
)
inline

Create a plane from a normal and distance (D) value.

Parameters
normalThe plane normal. Must be normalised.
distancethe plane D component.
Returns
The plane equation.

◆ fromNormalAndPoint()

template<typename T >
Vector4<T> tes::planegeom::fromNormalAndPoint ( const Vector3< T > &  normal,
const Vector3< T > &  pointOnPlane 
)

Create a plane from a normal and a point on the plane.

Parameters
normalThe plane normal. Must be normalised.
pointOnPlaneAn arbitrary point on the plane.
Returns
The plane equation.

References tes::Vector3< T >::dot().

◆ projectPoint()

template<typename T >
Vector3<T> tes::planegeom::projectPoint ( const Vector4< T > &  plane,
const Vector3< T > &  point 
)
inline

Project a point onto a plane.

Parameters
planeThe plane equation.
pointThe point of interest.
Returns
The closest point on the plane to point.

References signedDistanceToPoint(), and tes::Vector4< T >::xyz().

◆ signedDistanceToPoint()

template<typename T >
T tes::planegeom::signedDistanceToPoint ( const Vector4< T > &  plane,
const Vector3< T > &  point 
)
inline

Calculate the signed distance between the plane and point.

Positive is in front, negative behind and zero on.

Parameters
planeThe plane equation.
pointThe point of interest.
Returns
The shorted distance from point to the plane (signed).

References tes::Vector4< T >::xyz().

Referenced by classifyPoint(), and projectPoint().