My Project
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
ParaEngine::Plane Class Reference

Defines a plane in 3D space. More...

#include <ParaPlane.h>

Inheritance diagram for ParaEngine::Plane:
ParaEngine::CShapePlane ParaEngine::PCPlane

Public Types

enum  Side { NO_SIDE, POSITIVE_SIDE, NEGATIVE_SIDE, BOTH_SIDE }
 The "positive side" of the plane is the half space to which the plane normal points. More...
 

Public Member Functions

 Plane ()
 Default constructor - sets everything to 0.
 
 Plane (const Plane &rhs)
 
 Plane (const Vector3 &rkNormal, float fConstant)
 Construct a plane through a normal, and a distance to move the plane along the normal. More...
 
 Plane (float a, float b, float c, float d)
 Construct a plane using the 4 constants directly.
 
 Plane (const Vector3 &rkNormal, const Vector3 &rkPoint)
 
 Plane (const Vector3 &rkPoint0, const Vector3 &rkPoint1, const Vector3 &rkPoint2)
 
Side getSide (const Vector3 &rkPoint) const
 
Side getSide (const AxisAlignedBox &rkBox) const
 returns the side where the aligneBox is. More...
 
Side getSide (const CShapeAABB &rkBox) const
 returns the side where the aligneBox is. More...
 
Side getSide (const Vector3 &centre, const Vector3 &halfSize) const
 Returns which side of the plane that the given box lies on. More...
 
float getDistance (const Vector3 &rkPoint) const
 This is a pseudo distance. More...
 
void redefine (const Vector3 &rkPoint0, const Vector3 &rkPoint1, const Vector3 &rkPoint2)
 Redefine this plane based on 3 points. More...
 
void redefine (const Vector3 &rkNormal, const Vector3 &rkPoint)
 Redefine this plane based on a normal and a point. More...
 
PlaneSet (float nx, float ny, float nz, float _d)
 
PlaneSet (const Vector3 &p, const Vector3 &_n)
 
PlaneSet (const Vector3 &p0, const Vector3 &p1, const Vector3 &p2)
 
Vector3 projectVector (const Vector3 &v) const
 Project a vector onto the plane. More...
 
float normalise (void)
 Normalizes the plane. More...
 
float PlaneDotCoord (const Vector3 &pV) const
 
float PlaneDotNormal (const Vector3 &pV) const
 
Plane PlaneTransform (const Matrix4 &M) const
 
float a () const
 
float b () const
 
float c () const
 
 operator Vector3 () const
 
 operator Vector4 () const
 
Plane operator* (const Matrix4 &m) const
 
Planeoperator*= (const Matrix4 &m)
 
Plane operator- () const
 
 operator const float * () const
 
 operator float * ()
 
bool operator== (const Plane &rhs) const
 Comparison operator.
 
bool operator!= (const Plane &rhs) const
 

Public Attributes

Vector3 normal
 
float d
 

Friends

std::ostream & operator<< (std::ostream &o, const Plane &p)
 

Detailed Description

Defines a plane in 3D space.

Remarks
A plane is defined in 3D space by the equation Ax + By + Cz + D = 0
This equates to a vector (the normal of the plane, whose x, y and z components equate to the coefficients A, B and C respectively), and a constant (D) which is the distance along the normal you have to go to move the plane back to the origin.

Member Enumeration Documentation

§ Side

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.

Constructor & Destructor Documentation

§ Plane()

ParaEngine::Plane::Plane ( const Vector3 rkNormal,
float  fConstant 
)

Construct a plane through a normal, and a distance to move the plane along the normal.

Member Function Documentation

§ getDistance()

float ParaEngine::Plane::getDistance ( const Vector3 rkPoint) const

This is a pseudo distance.

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.

The absolute value of the return value is the true distance only when the plane normal is a unit length vector.

§ getSide() [1/3]

Plane::Side ParaEngine::Plane::getSide ( const AxisAlignedBox rkBox) const

returns the side where the aligneBox is.

the flag BOTH_SIDE indicates an intersecting box. one corner ON the plane is sufficient to consider the box and the plane intersecting.

§ getSide() [2/3]

Plane::Side ParaEngine::Plane::getSide ( const CShapeAABB rkBox) const

returns the side where the aligneBox is.

the flag BOTH_SIDE indicates an intersecting box. one corner ON the plane is sufficient to consider the box and the plane intersecting.

§ getSide() [3/3]

Plane::Side ParaEngine::Plane::getSide ( const Vector3 centre,
const Vector3 halfSize 
) const

Returns which side of the plane that the given box lies on.

The box is defined as centre/half-size pairs for effectively.

Parameters
centreThe centre of the box.
halfSizeThe half-size of the box.
Returns
POSITIVE_SIDE if the box complete lies on the "positive side" of the plane, NEGATIVE_SIDE if the box complete lies on the "negative side" of the plane, and BOTH_SIDE if the box intersects the plane.

§ normalise()

float ParaEngine::Plane::normalise ( void  )

Normalizes the plane.

Remarks
This method normalizes the plane's normal and the length scale of d is as well.
Note
This function will not crash for zero-sized vectors, but there will be no changes made to their components.
Returns
The previous length of the plane's normal.

§ projectVector()

Vector3 ParaEngine::Plane::projectVector ( const Vector3 v) const

Project a vector onto the plane.

Remarks
This gives you the element of the input vector that is perpendicular to the normal of the plane. You can get the element which is parallel to the normal of the plane by subtracting the result of this method from the original vector, since parallel + perpendicular = original.
Parameters
vThe input vector

§ redefine() [1/2]

void ParaEngine::Plane::redefine ( const Vector3 rkPoint0,
const Vector3 rkPoint1,
const Vector3 rkPoint2 
)

Redefine this plane based on 3 points.

§ redefine() [2/2]

void ParaEngine::Plane::redefine ( const Vector3 rkNormal,
const Vector3 rkPoint 
)

Redefine this plane based on a normal and a point.


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