CrystalSpace

Public API Reference

csPlane3 Class Reference
[Geometry utilities]

A plane in 3D space. More...

#include <csgeom/plane3.h>

List of all members.

Public Member Functions

float & A ()
 Return the A component of this plane.
float A () const
 Return the A component of this plane.
float & B ()
 Return the B component of this plane.
float B () const
 Return the B component of this plane.
float & C ()
 Return the C component of this plane.
float C () const
 Return the C component of this plane.
float Classify (const csVector3 &pt) const
 Classify the given vector with regards to this plane.
uint8 ClipPolygon (const csVector3 *InVerts, size_t InCount, csVector3 *OutPolygon, size_t &OutCount, csVertexStatus *OutStatus, bool reversed=false) const
 Clip the polygon in InVerts (having InCount vertices) to this plane.
bool ClipPolygon (csVector3 *&pverts, int &num_verts, bool reversed=false)
 Clip the polygon in pverts (having num_verts vertices) to this plane.
 csPlane3 (const csVector3 &v2, const csVector3 &v3)
 Initialize the plane through 0 and the two given points.
 csPlane3 (const csVector3 &v1, const csVector3 &v2, const csVector3 &v3)
 Initialize the plane through the three given points.
 csPlane3 (float a, float b, float c, float d=0)
 Initialize the plane to the given components.
 csPlane3 (const csVector3 &plane_norm, float d=0)
 Initialize the plane with the given norm and D component.
 csPlane3 ()
 Initialize to the xy plane (0,0,1,0).
float & D ()
 Return the D component of this plane.
float D () const
 Return the D component of this plane.
csString Description () const
 Return a textual representation of the plane in the form "aa,bb,cc,dd".
float Distance (const csVector3 &pt) const
 Compute the distance from the given vector to this plane.
csVector3 FindPoint () const
 Find a point on this plane.
const csVector3GetNormal () const
 Return the normal of this plane.
csPlane3 Inverse () const
 Return the same plane with inverted direction.
void Invert ()
 Reverses the direction of the plane while maintaining the plane itself.
const csVector3Normal () const
 Return the normal vector of this plane.
csVector3Normal ()
 Return the normal vector of this plane.
void Normalize ()
 Normalizes the plane equation so that 'norm' is a unit vector.
bool operator== (const csPlane3 &other) const
 Compare two planes.
void Set (const csVector3 &v2, const csVector3 &v3)
 Initialize the plane through 0 and the two given points.
void Set (const csVector3 &v1, const csVector3 &v2, const csVector3 &v3)
 Initialize the plane through the three given points.
void Set (const csVector3 &normal, float d)
 Set the value of the plane using a normal and D component.
void Set (float a, float b, float c, float d)
 Set the value of the four plane components.
void SetOrigin (const csVector3 &p)
 Set one point ("origin") through which the plane goes.



csVector3 ProjectOnto (const csVector3 &p) const
 Project a point onto this plane.
csVector3 ProjectOnto (const csVector3 &p)
 Project a point onto this plane.

Static Public Member Functions

static float Classify (float A, float B, float C, float D, const csVector3 &pt)
 This static function classifies a vector with regards to four given plane components.
static void FindOrthogonalPoints (const csVector3 &norm, csVector3 &p, csVector3 &q)
 Calculate two orthogonal points on the plane given by the normal 'norm' and going through the origin.

Public Attributes

float DD
 The D component of the plane.
csVector3 norm
 The normal vector (or the (A,B,C) components).

Friends

csPlane3 operator* (const CS::Math::Matrix4 &m_inv_t, const csPlane3 &p)
 Transform plane by the given matrix.

Detailed Description

A plane in 3D space.

The plane is given by the equation AAx + BBy + CCz + DD = 0, Where (AA,BB,CC) is given by the vector 'norm'.

Definition at line 43 of file plane3.h.


Constructor & Destructor Documentation

csPlane3::csPlane3 (  )  [inline]

Initialize to the xy plane (0,0,1,0).

Definition at line 55 of file plane3.h.

csPlane3::csPlane3 ( const csVector3 plane_norm,
float  d = 0 
) [inline]

Initialize the plane with the given norm and D component.

Definition at line 60 of file plane3.h.

csPlane3::csPlane3 ( float  a,
float  b,
float  c,
float  d = 0 
) [inline]

Initialize the plane to the given components.

Definition at line 65 of file plane3.h.

csPlane3::csPlane3 ( const csVector3 v1,
const csVector3 v2,
const csVector3 v3 
)

Initialize the plane through the three given points.

If the plane is expressed as (N,D) with N the A,B,C components of the plane then this will initialize the plane to (N',-N'*v1) with N' equal to (v1-v2)%(v1-v3).

csPlane3::csPlane3 ( const csVector3 v2,
const csVector3 v3 
) [inline]

Initialize the plane through 0 and the two given points.

If the plane is expressed as (N,D) with N the A,B,C components of the plane then this will initialize the plane to (v2v3,0).

Definition at line 80 of file plane3.h.


Member Function Documentation

float& csPlane3::A (  )  [inline]

Return the A component of this plane.

Definition at line 108 of file plane3.h.

float csPlane3::A (  )  const [inline]

Return the A component of this plane.

Definition at line 99 of file plane3.h.

float& csPlane3::B (  )  [inline]

Return the B component of this plane.

Definition at line 110 of file plane3.h.

float csPlane3::B (  )  const [inline]

Return the B component of this plane.

Definition at line 101 of file plane3.h.

float& csPlane3::C (  )  [inline]

Return the C component of this plane.

Definition at line 112 of file plane3.h.

float csPlane3::C (  )  const [inline]

Return the C component of this plane.

Definition at line 103 of file plane3.h.

static float csPlane3::Classify ( float  A,
float  B,
float  C,
float  D,
const csVector3 pt 
) [inline, static]

This static function classifies a vector with regards to four given plane components.

This will calculate and return A*pt.x+B*pt.y+C*pt.z+D.

Definition at line 170 of file plane3.h.

float csPlane3::Classify ( const csVector3 pt  )  const [inline]

Classify the given vector with regards to this plane.

If the plane is expressed as (N,D) with N the A,B,C components of the plane then this will calculate and return N*pt+D. Note that in the Crystal Space engine this function will return negative if used on the visible side of a polygon. i.e. if you take the world space plane of the polygon, then Classify() will return a negative value if the camera is located at a point from which you can see the polygon. Back-face culling will make the polygon invisible on the other side.

Definition at line 164 of file plane3.h.

uint8 csPlane3::ClipPolygon ( const csVector3 InVerts,
size_t  InCount,
csVector3 OutPolygon,
size_t &  OutCount,
csVertexStatus OutStatus,
bool  reversed = false 
) const

Clip the polygon in InVerts (having InCount vertices) to this plane.

Method returns one of CS_CLIP_OUTSIDE, CS_CLIP_INSIDE, CS_CLIP_CLIPPED depending on whether all, none or some vertices were clipped. If the polygon is clipped, the resulting polygon is returned in OutPolygon and the number of vertices in OutCount. OutCount must be initialized with the maximum number of output vertices. OutStatus will return additional information for clipped vertices. Normally this function will consider the polygon visible if it is on the negative side of the plane (Classify()). If reversed is set to true then the positive side will be used instead.

bool csPlane3::ClipPolygon ( csVector3 *&  pverts,
int &  num_verts,
bool  reversed = false 
)

Clip the polygon in pverts (having num_verts vertices) to this plane.

Method returns true if there is something visible, false otherwise. Note that this function returns a pointer to a static array in csPlane3. The contents of this array will only be valid until the next call to ClipPolygon. Normally this function will consider the polygon visible if it is on the negative side of the plane (Classify()). If 'reversed' is set to true then the positive side will be used instead.

float& csPlane3::D (  )  [inline]

Return the D component of this plane.

Definition at line 114 of file plane3.h.

float csPlane3::D (  )  const [inline]

Return the D component of this plane.

Definition at line 105 of file plane3.h.

csString csPlane3::Description (  )  const

Return a textual representation of the plane in the form "aa,bb,cc,dd".

float csPlane3::Distance ( const csVector3 pt  )  const [inline]

Compute the distance from the given vector to this plane.

This function assumes that 'norm' is a unit vector. If not, the function returns distance times the magnitude of 'norm'. This function corresponds exactly to the absolute value of Classify().

Definition at line 182 of file plane3.h.

static void csPlane3::FindOrthogonalPoints ( const csVector3 norm,
csVector3 p,
csVector3 q 
) [static]

Calculate two orthogonal points on the plane given by the normal 'norm' and going through the origin.

This gives an axis on that plane.

csVector3 csPlane3::FindPoint (  )  const

Find a point on this plane.

const csVector3& csPlane3::GetNormal (  )  const [inline]

Return the normal of this plane.

Definition at line 117 of file plane3.h.

csPlane3 csPlane3::Inverse (  )  const [inline]

Return the same plane with inverted direction.

Definition at line 192 of file plane3.h.

void csPlane3::Invert (  )  [inline]

Reverses the direction of the plane while maintaining the plane itself.

This will basically reverse the result of Classify().

Definition at line 189 of file plane3.h.

const csVector3& csPlane3::Normal (  )  const [inline]

Return the normal vector of this plane.

Definition at line 96 of file plane3.h.

csVector3& csPlane3::Normal (  )  [inline]

Return the normal vector of this plane.

Definition at line 94 of file plane3.h.

void csPlane3::Normalize (  )  [inline]

Normalizes the plane equation so that 'norm' is a unit vector.

Definition at line 197 of file plane3.h.

bool csPlane3::operator== ( const csPlane3 other  )  const [inline]

Compare two planes.

Definition at line 88 of file plane3.h.

csVector3 csPlane3::ProjectOnto ( const csVector3 p  )  const [inline]

Project a point onto this plane.

Definition at line 213 of file plane3.h.

csVector3 csPlane3::ProjectOnto ( const csVector3 p  ) 

Project a point onto this plane.

void csPlane3::Set ( const csVector3 v2,
const csVector3 v3 
) [inline]

Initialize the plane through 0 and the two given points.

If the plane is expressed as (N,D) with N the A,B,C components of the plane then this will initialize the plane to (v2v3,0).

Definition at line 140 of file plane3.h.

void csPlane3::Set ( const csVector3 v1,
const csVector3 v2,
const csVector3 v3 
)

Initialize the plane through the three given points.

If the plane is expressed as (N,D) with N the A,B,C components of the plane then this will initialize the plane to (N',-N'*v1) with N' equal to (v1-v2)%(v1-v3).

void csPlane3::Set ( const csVector3 normal,
float  d 
) [inline]

Set the value of the plane using a normal and D component.

Definition at line 124 of file plane3.h.

void csPlane3::Set ( float  a,
float  b,
float  c,
float  d 
) [inline]

Set the value of the four plane components.

Definition at line 120 of file plane3.h.

void csPlane3::SetOrigin ( const csVector3 p  )  [inline]

Set one point ("origin") through which the plane goes.

This is equal to setting DD = -N'*p where N' is the normal

Definition at line 149 of file plane3.h.


Friends And Related Function Documentation

csPlane3 operator* ( const CS::Math::Matrix4 m_inv_t,
const csPlane3 p 
) [friend]

Transform plane by the given matrix.

For a correct result, m_inv_t must be the transposed inverse of the matrix by which you want to actually transform.

Definition at line 266 of file plane3.h.


Member Data Documentation

float csPlane3::DD

The D component of the plane.

Definition at line 50 of file plane3.h.

The normal vector (or the (A,B,C) components).

Definition at line 47 of file plane3.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1