Saga3D API Documentation  1.0-RC4
saga::core::plane3d< T > Class Template Reference

Template plane class with some intersection testing methods. More...

#include <plane3d.h>

Public Member Functions

 plane3d ()
 
 plane3d (const glm::vec3 &MPoint, const glm::vec3 &Normal)
 
 plane3d (T px, T py, T pz, T nx, T ny, T nz)
 
 plane3d (const glm::vec3 &point1, const glm::vec3 &point2, const glm::vec3 &point3)
 
 plane3d (const glm::vec3 &normal, const T d)
 
bool operator== (const plane3d< T > &other) const
 
bool operator!= (const plane3d< T > &other) const
 
void setPlane (const glm::vec3 &point, const glm::vec3 &nvector)
 
void setPlane (const glm::vec3 &nvect, T d)
 
void setPlane (const glm::vec3 &point1, const glm::vec3 &point2, const glm::vec3 &point3)
 
void transform (const glm::mat4 &mat)
 
bool getIntersectionWithLine (const glm::vec3 &linePoint, const glm::vec3 &lineVect, glm::vec3 &outIntersection) const
 Get an intersection with a 3d line. More...
 
float getKnownIntersectionWithLine (const glm::vec3 &linePoint1, const glm::vec3 &linePoint2) const
 Get percentage of line between two points where an intersection with this plane happens. More...
 
bool getIntersectionWithLimitedLine (const glm::vec3 &linePoint1, const glm::vec3 &linePoint2, glm::vec3 &outIntersection) const
 Get an intersection with a 3d line, limited between two 3d points. More...
 
EIntersectionRelation3D classifyPointRelation (const glm::vec3 &point) const
 Classifies the relation of a point to this plane. More...
 
void recalculateD (const glm::vec3 &MPoint)
 Recalculates the distance from origin by applying a new member point to the plane. More...
 
glm::vec3 getMemberPoint () const
 Gets a member point of the plane. More...
 
bool existsIntersection (const plane3d< T > &other) const
 Tests if there is an intersection with the other plane. More...
 
bool getIntersectionWithPlane (const plane3d< T > &other, glm::vec3 &outLinePoint, glm::vec3 &outLineVect) const
 Intersects this plane with another. More...
 
bool getIntersectionWithPlanes (const plane3d< T > &o1, const plane3d< T > &o2, glm::vec3 &outPoint) const
 Get the intersection point with two other planes if there is one. More...
 
bool isFrontFacing (const glm::vec3 &lookDirection) const
 Test if the triangle would be front or backfacing from any point. More...
 
getDistanceTo (const glm::vec3 &point) const
 Get the distance to a point. More...
 

Public Attributes

glm::vec3 Normal
 Normal vector of the plane. More...
 
D
 Distance from origin. More...
 

Detailed Description

template<class T>
class saga::core::plane3d< T >

Template plane class with some intersection testing methods.

It has to be ensured, that the normal is always normalized. The constructors and setters of this class will not ensure this automatically. So any normal passed in has to be normalized in advance. No change to the normal will be made by any of the class methods.

Definition at line 34 of file plane3d.h.

Constructor & Destructor Documentation

◆ plane3d() [1/5]

template<class T >
saga::core::plane3d< T >::plane3d ( )
inline

Definition at line 40 of file plane3d.h.

◆ plane3d() [2/5]

template<class T >
saga::core::plane3d< T >::plane3d ( const glm::vec3 &  MPoint,
const glm::vec3 &  Normal 
)
inline

Definition at line 42 of file plane3d.h.

◆ plane3d() [3/5]

template<class T >
saga::core::plane3d< T >::plane3d ( px,
py,
pz,
nx,
ny,
nz 
)
inline

Definition at line 44 of file plane3d.h.

◆ plane3d() [4/5]

template<class T >
saga::core::plane3d< T >::plane3d ( const glm::vec3 &  point1,
const glm::vec3 &  point2,
const glm::vec3 &  point3 
)
inline

Definition at line 46 of file plane3d.h.

◆ plane3d() [5/5]

template<class T >
saga::core::plane3d< T >::plane3d ( const glm::vec3 &  normal,
const T  d 
)
inline

Definition at line 49 of file plane3d.h.

Member Function Documentation

◆ classifyPointRelation()

template<class T >
EIntersectionRelation3D saga::core::plane3d< T >::classifyPointRelation ( const glm::vec3 &  point) const
inline

Classifies the relation of a point to this plane.

Parameters
pointPoint to classify its relation.
Returns
ISREL3D_FRONT if the point is in front of the plane, ISREL3D_BACK if the point is behind of the plane, and ISREL3D_PLANAR if the point is within the plane.

Definition at line 148 of file plane3d.h.

◆ existsIntersection()

template<class T >
bool saga::core::plane3d< T >::existsIntersection ( const plane3d< T > &  other) const
inline

Tests if there is an intersection with the other plane.

Returns
True if there is a intersection.

Definition at line 175 of file plane3d.h.

◆ getDistanceTo()

template<class T >
T saga::core::plane3d< T >::getDistanceTo ( const glm::vec3 &  point) const
inline

Get the distance to a point.

Note that this only works if the normal is normalized.

Definition at line 235 of file plane3d.h.

◆ getIntersectionWithLimitedLine()

template<class T >
bool saga::core::plane3d< T >::getIntersectionWithLimitedLine ( const glm::vec3 &  linePoint1,
const glm::vec3 &  linePoint2,
glm::vec3 &  outIntersection 
) const
inline

Get an intersection with a 3d line, limited between two 3d points.

Parameters
linePoint1Point 1 of the line.
linePoint2Point 2 of the line.
outIntersectionPlace to store the intersection point, if there is one.
Returns
True if there was an intersection, false if there was not.

Definition at line 134 of file plane3d.h.

◆ getIntersectionWithLine()

template<class T >
bool saga::core::plane3d< T >::getIntersectionWithLine ( const glm::vec3 &  linePoint,
const glm::vec3 &  lineVect,
glm::vec3 &  outIntersection 
) const
inline

Get an intersection with a 3d line.

Parameters
lineVectVector of the line to intersect with.
linePointPoint of the line to intersect with.
outIntersectionPlace to store the intersection point, if there is one.
Returns
True if there was an intersection, false if there was not.

Definition at line 99 of file plane3d.h.

◆ getIntersectionWithPlane()

template<class T >
bool saga::core::plane3d< T >::getIntersectionWithPlane ( const plane3d< T > &  other,
glm::vec3 &  outLinePoint,
glm::vec3 &  outLineVect 
) const
inline

Intersects this plane with another.

Parameters
otherOther plane to intersect with.
outLinePointBase point of intersection line.
outLineVectVector of intersection.
Returns
True if there is a intersection, false if not.

Definition at line 186 of file plane3d.h.

◆ getIntersectionWithPlanes()

template<class T >
bool saga::core::plane3d< T >::getIntersectionWithPlanes ( const plane3d< T > &  o1,
const plane3d< T > &  o2,
glm::vec3 &  outPoint 
) const
inline

Get the intersection point with two other planes if there is one.

Definition at line 208 of file plane3d.h.

◆ getKnownIntersectionWithLine()

template<class T >
float saga::core::plane3d< T >::getKnownIntersectionWithLine ( const glm::vec3 &  linePoint1,
const glm::vec3 &  linePoint2 
) const
inline

Get percentage of line between two points where an intersection with this plane happens.

Only useful if known that there is an intersection.

Parameters
linePoint1Point1 of the line to intersect with.
linePoint2Point2 of the line to intersect with.
Returns
Where on a line between two points an intersection with this plane happened. For example, 0.5 is returned if the intersection happened exactly in the middle of the two points.

Definition at line 120 of file plane3d.h.

◆ getMemberPoint()

template<class T >
glm::vec3 saga::core::plane3d< T >::getMemberPoint ( ) const
inline

Gets a member point of the plane.

Definition at line 168 of file plane3d.h.

◆ isFrontFacing()

template<class T >
bool saga::core::plane3d< T >::isFrontFacing ( const glm::vec3 &  lookDirection) const
inline

Test if the triangle would be front or backfacing from any point.

Thus, this method assumes a camera position from which the triangle is definitely visible when looking into the given direction. Note that this only works if the normal is Normalized. Do not use this method with points as it will give wrong results!

Parameters
lookDirectionLook direction.
Returns
True if the plane is front facing and false if it is backfacing.

Definition at line 227 of file plane3d.h.

◆ operator!=()

template<class T >
bool saga::core::plane3d< T >::operator!= ( const plane3d< T > &  other) const
inline

Definition at line 55 of file plane3d.h.

◆ operator==()

template<class T >
bool saga::core::plane3d< T >::operator== ( const plane3d< T > &  other) const
inline

Definition at line 53 of file plane3d.h.

◆ recalculateD()

template<class T >
void saga::core::plane3d< T >::recalculateD ( const glm::vec3 &  MPoint)
inline

Recalculates the distance from origin by applying a new member point to the plane.

Definition at line 162 of file plane3d.h.

◆ setPlane() [1/3]

template<class T >
void saga::core::plane3d< T >::setPlane ( const glm::vec3 &  nvect,
d 
)
inline

Definition at line 65 of file plane3d.h.

◆ setPlane() [2/3]

template<class T >
void saga::core::plane3d< T >::setPlane ( const glm::vec3 &  point,
const glm::vec3 &  nvector 
)
inline

Definition at line 59 of file plane3d.h.

◆ setPlane() [3/3]

template<class T >
void saga::core::plane3d< T >::setPlane ( const glm::vec3 &  point1,
const glm::vec3 &  point2,
const glm::vec3 &  point3 
)
inline

Definition at line 71 of file plane3d.h.

◆ transform()

template<class T >
void saga::core::plane3d< T >::transform ( const glm::mat4 &  mat)
inline

Definition at line 81 of file plane3d.h.

Member Data Documentation

◆ D

template<class T >
T saga::core::plane3d< T >::D

Distance from origin.

Definition at line 244 of file plane3d.h.

◆ Normal

template<class T >
glm::vec3 saga::core::plane3d< T >::Normal

Normal vector of the plane.

Definition at line 241 of file plane3d.h.


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