# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CPlane Class Reference

Class CPlane. More...

#include <plane.h>

List of all members.

Public Methods

Object.
 CPlane ()
 Constructor that does nothing. More...

 CPlane (float _a, float _b, float _c, float _d)
 Constructor . More...

 CPlane (const CPlane &v)
 Copy Constructor. More...

Construction/Get.
void make (const CVector &normal, const CVector &pos)
 Make a plane with a normal and a vertex. More...

void make (const CVector &p0, const CVector &p1, const CVector &p2)
 Make a plane with 3 vertices. More...

CVector getNormal () const
 Return the normal vector of the plane. More...

void normalize ()
 Normalize the plane, such that getNormal() return a normalized vector. More...

CPlane normed () const
 return the normalized version of a plane. More...

Projection / clipping.
float distance (const CVector &p) const
 Return the distance of p from the plane. More...

float operator * (const CVector &p) const
 Return plane*vector. More...

CVector intersect (const CVector &p0, const CVector &p1) const
 Intersect a line onto a plane. p1 is returned if line // to plane. More...

CVector project (const CVector &p0) const
 Project a point onto a plane. More...

bool clipSegmentBack (CVector &p0, CVector &p1) const
 Clip a segment onto a plane. More...

bool clipSegmentFront (CVector &p0, CVector &p1) const
 Clip a segment onto a plane. More...

sint clipPolygonBack (CVector in[], CVector out[], sint nIn) const
 Clip a polygon by a plane. More...

sint clipPolygonFront (CVector in[], CVector out[], sint nIn) const
 Clip a polygon by a plane. More...

normal inversion
CPlane inverted () const
 get the inverted version of this plane (same position, but inverted normal). More...

void invert ()
 invert this plane (same position, but inverted normal). More...

Misc
void serial (IStream &f)

Public Attributes

float a
float b
float c
float d


Detailed Description

Class CPlane.

a 3D Plane.

A vector v is said "front" of a plane p if p*v>0.

A "front segment" or a "front polygon" have all their vertices in front of the plane.

Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 49 of file plane.h.


Constructor & Destructor Documentation

NLMISC::CPlane::CPlane   [inline]
 

Constructor that does nothing.

Definition at line 59 of file plane.h.

Referenced by CPlane, distance, inverted, and normed.

NLMISC::CPlane::CPlane float    _a,
float    _b,
float    _c,
float    _d
[inline]
 

Constructor .

Definition at line 61 of file plane.h.

References a, b, c, and d.

NLMISC::CPlane::CPlane const CPlane &    v [inline]
 

Copy Constructor.

Definition at line 63 of file plane.h.

References a, b, c, CPlane, d, and v.


Member Function Documentation

sint NLMISC::CPlane::clipPolygonBack CVector    in[],
CVector    out[],
sint    nIn
const
 

Clip a polygon by a plane.

The "back polygon" is returned. Nb: Out must be allocated to nIn+1 (at less).

Parameters:
in  the input polygon
out  the clipped back polygon
nIn  number of vertices of input polygon
Returns:
number of vertices of out. 0 is returned if In polygon entirely front, or if nIn<=2.

Definition at line 97 of file plane.cpp.

References in, intersect, and s.

sint NLMISC::CPlane::clipPolygonFront CVector    in[],
CVector    out[],
sint    nIn
const
 

Clip a polygon by a plane.

The "front polygon" is returned. Nb: Out must be allocated to nIn+1 (at less).

Parameters:
in  the input polygon
out  the clipped front polygon
nIn  number of vertices of input polygon
Returns:
number of vertices of out. 0 is returned if In polygon entirely back, or if nIn<=2.

Definition at line 125 of file plane.cpp.

References in, intersect, and s.

Referenced by NL3D::CCubeGrid::project.

bool NLMISC::CPlane::clipSegmentBack CVector   p0,
CVector   p1
const
 

Clip a segment onto a plane.

The "back segment" is written in (p1,p2). If segment is entirely "front", (p1,p2) is not modified.

Returns:
false if segment entirely front, or true.
See also:
clipSegmentFront()

Definition at line 54 of file plane.cpp.

bool NLMISC::CPlane::clipSegmentFront CVector   p0,
CVector   p1
const
 

Clip a segment onto a plane.

The "front segment" is written in (p1,p2). If segment is entirely "back", (p1,p2) is not modified.

Returns:
false if segment entirely back, or true.
See also:
clipSegmentBack()

Definition at line 74 of file plane.cpp.

float NLMISC::CPlane::distance const CVector   p const [inline]
 

Return the distance of p from the plane.

Hence, the result is >=0. Since the plane normal may not be normalized, distance() compute the distance with the normalized normal of plane. If you are sure that your plane has a normalized normal, it is much faster to do a fabs(p*v).

Definition at line 40 of file plane_inline.h.

References CPlane, normed, and v.

CVector NLMISC::CPlane::getNormal   const [inline]
 

Return the normal vector of the plane.

Since the normal of the plane may not be normalized (if setuped without make()), the returned normal may NOT be normalized.

Definition at line 35 of file plane_inline.h.

References a, b, and c.

Referenced by normalize, NL3D::CPSZoneRectangle::performMotion, NL3D::CPSZoneDisc::performMotion, NL3D::CPSZonePlane::performMotion, and project.

CVector NLMISC::CPlane::intersect const CVector   p0,
const CVector   p1
const [inline]
 

Intersect a line onto a plane. p1 is returned if line // to plane.

Definition at line 51 of file plane_inline.h.

References a, and b.

Referenced by clipPolygonBack, clipPolygonFront, project, NL3D::CCubeGrid::project, and NL3D::CCubeGrid::select.

void NLMISC::CPlane::invert  
 

invert this plane (same position, but inverted normal).

Definition at line 160 of file plane.cpp.

References a, b, c, and d.

CPlane NLMISC::CPlane::inverted   const
 

get the inverted version of this plane (same position, but inverted normal).

Definition at line 154 of file plane.cpp.

References a, b, c, CPlane, and d.

void NLMISC::CPlane::make const CVector   p0,
const CVector   p1,
const CVector   p2
 

Make a plane with 3 vertices.

NB: the plane normal is normalized by make().

Definition at line 44 of file plane.cpp.

References make, and v.

void NLMISC::CPlane::make const CVector   normal,
const CVector   pos
 

Make a plane with a normal and a vertex.

NB: the plane normal is normalized by make().

Definition at line 36 of file plane.cpp.

References a, b, c, d, and v.

Referenced by NL3D::CCubeGrid::insert, make, NL3D::CHeatHaze::performHeatHaze, NL3D::CPSZoneRectangle::performMotion, NL3D::CPSZoneDisc::performMotion, NL3D::CPSZonePlane::performMotion, NL3D::CCubeGrid::select, NL3D::CQuadTree::selectRay, NL3D::CQuadTree::selectSegment, and NL3D::CWaterRenderObs::traverse.

void NLMISC::CPlane::normalize   [inline]
 

Normalize the plane, such that getNormal() return a normalized vector.

Definition at line 68 of file plane_inline.h.

References a, b, c, d, and getNormal.

CPlane NLMISC::CPlane::normed   const [inline]
 

return the normalized version of a plane.

See also:
normalize()

Definition at line 81 of file plane_inline.h.

References CPlane.

Referenced by distance.

float NLMISC::CPlane::operator * const CVector   p const [inline]
 

Return plane*vector.

Definition at line 46 of file plane_inline.h.

References a, b, c, and d.

CVector NLMISC::CPlane::project const CVector   p0 const [inline]
 

Project a point onto a plane.

Definition at line 62 of file plane_inline.h.

References getNormal, and intersect.

void NLMISC::CPlane::serial IStream   f [inline]
 

Definition at line 155 of file plane.h.

References a, b, c, and d.


Member Data Documentation

float NLMISC::CPlane::a
 

Definition at line 52 of file plane.h.

Referenced by CPlane, getNormal, intersect, invert, inverted, make, normalize, operator *, NL3D::CHeatHaze::performHeatHaze, and serial.

float NLMISC::CPlane::b
 

Definition at line 52 of file plane.h.

Referenced by CPlane, getNormal, intersect, invert, inverted, make, normalize, operator *, and serial.

float NLMISC::CPlane::c
 

Definition at line 52 of file plane.h.

Referenced by CPlane, getNormal, invert, inverted, make, normalize, operator *, NL3D::CHeatHaze::performHeatHaze, and serial.

float NLMISC::CPlane::d
 

Definition at line 52 of file plane.h.

Referenced by CPlane, invert, inverted, make, normalize, operator *, NL3D::CHeatHaze::performHeatHaze, serial, and NL3D::CWaterRenderObs::traverse.


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