Cafu Engine
Plane3T< T > Class Template Reference

This class represents a plane in three-dimensional space. More...

#include "Plane3.hpp"

Public Member Functions

 Plane3T ()
 The default constructor. More...
 
 Plane3T (const Vector3T< T > &Normal_, T Dist_)
 An explicit constructor. More...
 
 Plane3T (const Vector3T< T > &A, const Vector3T< T > &B, const Vector3T< T > &C, const T Epsilon)
 This constructor creates the plane that contains the points ABC in clockwise order. More...
 
bool IsValid () const
 Returns true if the plane is valid, that is, if the normal vector is valid and (roughly) has length 1. More...
 
void GetSpanVectors (Vector3T< T > &U, Vector3T< T > &V) const
 Compute two orthogonal span vectors for this plane. More...
 
void GetSpanVectorsByRotation (Vector3T< T > &U, Vector3T< T > &V) const
 Compute two orthogonal span vectors for this plane, using a different method than GetSpanVectors(). More...
 
Plane3T GetMirror () const
 Returns the same, but mirrored plane, i.e. the plane with the reversed orientation. More...
 
GetDistance (const Vector3T< T > &A) const
 Determines the distance from A to this plane. More...
 
Vector3T< T > GetIntersection (const Vector3T< T > &A, const Vector3T< T > &B, const T cosEpsilon) const
 Intersect the line through A and B with this plane. More...
 
bool operator== (const Plane3T &P) const
 Returns whether this plane and plane P are truly (bit-wise) identical. More...
 
bool operator!= (const Plane3T &P) const
 Returns whether this plane and plane P are not equal (bit-wise). More...
 

Static Public Member Functions

static Vector3T< T > GetIntersection (const Plane3T &P1, const Plane3T &P2, const Plane3T &P3)
 Builds the intersection of three planes. More...
 
static void ConvexHull (const ArrayT< Vector3T< T > > &Points, ArrayT< Plane3T > &HullPlanes, ArrayT< unsigned long > *HullPlanesPIs, const T Epsilon)
 Computes the convex hull of a set of points. More...
 

Public Attributes

Vector3T< T > Normal
 Normal vector of this plane. More...
 
Dist
 Distance to origin (0, 0, 0). More...
 

Detailed Description

template<class T>
class Plane3T< T >

This class represents a plane in three-dimensional space.

Eigenschaften der Ebene (Vereinbarungen):

  1. Die Ebenengleichung lautet VectorDot(UnitNormal,x)=Dist
  2. Der Normalenvektor muß stets der EINHEITSnormalenvektor sein (Länge 1)
  3. ==> Einen Stützvektor erhalten wir aus VectorScale(UnitNormal,Dist)
  4. Der vordere Halbraum / die Oberseite der Ebene liegt in Richtung des Normalenvektors (Siehe auch: Mathematikheft Nr. 5, 24.01.96, "Die Bedeutung des Vorzeichens", Fälle 2+4)

Constructor & Destructor Documentation

template<class T>
Plane3T< T >::Plane3T ( )
inline

The default constructor.

template<class T>
Plane3T< T >::Plane3T ( const Vector3T< T > &  Normal_,
Dist_ 
)
inline

An explicit constructor.

template<class T>
Plane3T< T >::Plane3T ( const Vector3T< T > &  A,
const Vector3T< T > &  B,
const Vector3T< T > &  C,
const T  Epsilon 
)
inline

This constructor creates the plane that contains the points ABC in clockwise order.

The normal vector then points towards the observer (orientation!).

Parameters
AFirst point.
BSecond point.
CThird point.
EpsilonTolerance value.
Exceptions
DivisionByZeroEif cross(C-A, B-A) yields a vector shorter than Epsilon.

Member Function Documentation

template<class T>
void Plane3T< T >::ConvexHull ( const ArrayT< Vector3T< T > > &  Points,
ArrayT< Plane3T< T > > &  HullPlanes,
ArrayT< unsigned long > *  HullPlanesPIs,
const T  Epsilon 
)
static

Computes the convex hull of a set of points.

Parameters
PointsThe set of points for which the convex hull is computed.
HullPlanesThe array in which the convex hull planes are returned.
HullPlanesPIsIf non-NULL, in this array are triples of indices into Points returned, where the i-th triple indicates from which points the i-th hull plane was built.
EpsilonIn order to fight rounding errors, the "thickness" of a hull plane is assumed to be 2*Epsilon.
template<class T>
T Plane3T< T >::GetDistance ( const Vector3T< T > &  A) const
inline

Determines the distance from A to this plane.

template<class T>
Vector3T<T> Plane3T< T >::GetIntersection ( const Vector3T< T > &  A,
const Vector3T< T > &  B,
const T  cosEpsilon 
) const
inline

Intersect the line through A and B with this plane.

Parameters
AFirst point of the line.
BSecond point of the line.
cosEpsilonIf the angle between the planes normal vector and AB is too close to 90 degrees, AB roughly parallels the plane. The cosine of this angle is then close to 0. This value defines the minimally allowed cosine for which AB is considered not paralleling the plane.
Exceptions
DivisionByZeroEif AB parallels the plane too much.
template<class T>
static Vector3T<T> Plane3T< T >::GetIntersection ( const Plane3T< T > &  P1,
const Plane3T< T > &  P2,
const Plane3T< T > &  P3 
)
inlinestatic

Builds the intersection of three planes.

Parameters
P1First plane.
P2Second plane.
P3Third plane.
Exceptions
DivisionByZeroEif the intersection of the three planes has not exactly one solution.
template<class T>
Plane3T Plane3T< T >::GetMirror ( ) const
inline

Returns the same, but mirrored plane, i.e. the plane with the reversed orientation.

template<class T>
void Plane3T< T >::GetSpanVectors ( Vector3T< T > &  U,
Vector3T< T > &  V 
) const
inline

Compute two orthogonal span vectors for this plane.

template<class T>
void Plane3T< T >::GetSpanVectorsByRotation ( Vector3T< T > &  U,
Vector3T< T > &  V 
) const
inline

Compute two orthogonal span vectors for this plane, using a different method than GetSpanVectors().

Parameters
UFirst span vector.
VSecond span vector. TODO: Is this method more robust than GetSpanVectors()? See the implementation of GetSpanVectors() to understand the problem. That is, does this method not produce very different span vectors for very similar planes in some rare cases? If I understand atan2() correctly, it's two parameters refer to the Gegenkathete and Ankathete of an orthogonal triangle. Thus, atan2() should be able to operate smoothly even if one of its arguments is zero or near-zero. This seems to imply the smoothness of its results, and thus the robustness of this method, which solves the problem. But what if they are both zero? Does atan2() then yield an error? Or 0? Is its behaviour then consistent across platforms?
template<class T>
bool Plane3T< T >::IsValid ( ) const
inline

Returns true if the plane is valid, that is, if the normal vector is valid and (roughly) has length 1.

template<class T>
bool Plane3T< T >::operator!= ( const Plane3T< T > &  P) const
inline

Returns whether this plane and plane P are not equal (bit-wise).

Use this operator with care, as it comes without any epsilon threshold for taking rounding errors into account.

Parameters
PPlane to compare to.
template<class T>
bool Plane3T< T >::operator== ( const Plane3T< T > &  P) const
inline

Returns whether this plane and plane P are truly (bit-wise) identical.

Use this operator with care, as it comes without any epsilon threshold for taking rounding errors into account.

Parameters
PPlane to compare to.

Member Data Documentation

template<class T>
T Plane3T< T >::Dist

Distance to origin (0, 0, 0).

template<class T>
Vector3T<T> Plane3T< T >::Normal

Normal vector of this plane.


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