From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03082.html | 1203 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1203 insertions(+) create mode 100644 docs/doxygen/nel/a03082.html (limited to 'docs/doxygen/nel/a03082.html') diff --git a/docs/doxygen/nel/a03082.html b/docs/doxygen/nel/a03082.html new file mode 100644 index 00000000..3be8a59b --- /dev/null +++ b/docs/doxygen/nel/a03082.html @@ -0,0 +1,1203 @@ + + +NeL: NLMISC::CPlane class Reference + + + +
+

NLMISC::CPlane Class Reference

#include <plane.h> +

+


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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

Projection / clipping.
sint clipPolygonBack (CVector in[], CVector out[], sint nIn) const
sint clipPolygonFront (CVector in[], CVector out[], sint nIn) const
bool clipSegmentBack (CVector &p0, CVector &p1) const
bool clipSegmentFront (CVector &p0, CVector &p1) const
float distance (const CVector &p) const
CVector intersect (const CVector &p0, const CVector &p1) const
 Intersect a line onto a plane. p1 is returned if line // to plane.

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

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

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

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

 CPlane ()
 Constructor that does nothing.

Construction/Get.
CVector getNormal () const
void make (const CVector &p0, const CVector &p1, const CVector &p2)
void make (const CVector &normal, const CVector &pos)
void normalize ()
CPlane normed () const
normal inversion
void invert ()
 invert this plane (same position, but inverted normal)

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

Misc
bool operator== (const CPlane &o) const
void serial (IStream &f)

Data Fields

float a
float b
float c
float d
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLMISC::CPlane::CPlane  )  [inline]
+
+ + + + + +
+   + + +

+Constructor that does nothing. +

+ +

+Definition at line 59 of file plane.h. +

+Referenced by inverted(). +

+

00059 {}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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. +

+

00061 : a(_a), b(_b), c(_c), d(_d) {}
+
+

+ + + + +
+ + + + + + + + + + +
NLMISC::CPlane::CPlane const CPlane v  )  [inline]
+
+ + + + + +
+   + + +

+Copy Constructor. +

+ +

+Definition at line 63 of file plane.h. +

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

+

00063 : a(v.a), b(v.b), c(v.c), d(v.d) {}
+
+


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(), s, and sint. +

+Referenced by NLMISC::CPolygon::clip(), and NL3D::CCameraCol::minimizeDistanceAgainstTri(). +

+

00098 {
+00099         sint nOut=0,s,p,i;
+00100         if(nIn<=2) return 0;
+00101 
+00102         s=nIn-1;
+00103 
+00104         for (i=0;i<nIn;i++)
+00105         {
+00106                 p=i;
+00107                 if ( (*this)*in[p] < 0 )
+00108                 {
+00109                         if ( (*this)*in[s] > 0 ) 
+00110                                 out[nOut++]= intersect(in[s],in[p]);
+00111                         out[nOut++]=in[p];
+00112                 }
+00113                 else
+00114                 {
+00115                         if ( (*this)*in[s] < 0 ) 
+00116                                 out[nOut++]= intersect(in[s],in[p]);
+00117                 }
+00118                 s=p;
+00119         }
+00120 
+00121         return nOut;
+00122 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
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(), s, and sint. +

+Referenced by NL3D::CCubeGrid< TCell >::project(). +

+

00126 {
+00127         sint nOut=0,s,p,i;
+00128         if(nIn<=2) return 0;
+00129 
+00130         s=nIn-1;
+00131 
+00132         for (i=0;i<nIn;i++)
+00133         {
+00134                 p=i;
+00135                 if ( (*this)*in[p] > 0 )
+00136                 {
+00137                         if ( (*this)*in[s] < 0 ) 
+00138                                 out[nOut++]= intersect(in[s],in[p]);
+00139                         out[nOut++]=in[p];
+00140                 }
+00141                 else
+00142                 {
+00143                         if ( (*this)*in[s] > 0 ) 
+00144                                 out[nOut++]= intersect(in[s],in[p]);
+00145                 }
+00146                 s=p;
+00147         }
+00148 
+00149         return nOut;
+00150 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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. +

+Referenced by NLMISC::CAABBox::clipSegment(), and NLMISC::CAABBox::intersect(). +

+

00055 {
+00056         float   d0,d1,decal;
+00057         CVector proj;
+00058 
+00059         d0= (*this)*p0;
+00060         d1= (*this)*p1;
+00061         if(d0<0 && d1<0)
+00062                 return true;
+00063         if(d0>=0 && d1>=0)
+00064                 return false;
+00065         // Clip line.
+00066         decal= (0-d0) / (d1-d0);
+00067         proj= p0+ (p1-p0)*decal;
+00068         if(d0>=0)
+00069                 p0=proj;
+00070         else
+00071                 p1=proj;
+00072         return true;
+00073 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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. +

+

00075 {
+00076         float   d0,d1,decal;
+00077         CVector proj;
+00078 
+00079         d0= (*this)*p0;
+00080         d1= (*this)*p1;
+00081         if(d0>=0 && d1>=0)
+00082                 return true;
+00083         if(d0<0 && d1<0)
+00084                 return false;
+00085         // Clip line.
+00086         decal= (0-d0) / (d1-d0);
+00087         proj= p0+ (p1-p0)*decal;
+00088         if(d0<0)
+00089                 p0=proj;
+00090         else
+00091                 p1=proj;
+00092         return true;
+00093 }
+
+

+ + + + +
+ + + + + + + + + + +
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 normed(), and v. +

+

00041 {
+00042         CPlane  p= normed();
+00043         return (float)fabs(p*v);
+00044 }
+
+

+ + + + +
+ + + + + + + + + +
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 NL3D::CZoneLighter::buildZoneInformation(), NL3D::CPortal::clipRay(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CMiniCol::getGroundNormal(), NLSOUND::CClusteredSound::getPolyNearestPos(), NL3D::CCameraCol::minimizeDistanceAgainstTri(), normalize(), NL3D::CPSZoneRectangle::performMotion(), NL3D::CPSZoneDisc::performMotion(), NL3D::CPSZonePlane::performMotion(), project(), and NL3D::CRenderZBuffer::run(). +

+

00036 {
+00037         return CVector(a,b,c);
+00038 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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. +

+Referenced by clipPolygonBack(), clipPolygonFront(), NL3D::CMiniCol::getGroundNormal(), NLPACS::CLocalRetriever::getHeight(), NLMISC::CBSPNode2v::insert(), NL3D::CEvent3dMouseListener::operator()(), project(), NL3D::CCubeGrid< TCell >::project(), NL3D::CCubeGrid< TCell >::select(), NL3D::CMiniCol::snapToGround(), NLPACS::CLocalRetriever::snapToInteriorGround(), and NL3D::CVisualCollisionEntity::triangleIntersect(). +

+

00052 {
+00053         float decal;
+00054         float   da= (*this)*p0;
+00055         float   db= (*this)*p1;
+00056         if(db-da == 0)
+00057                 return p0;
+00058         decal= ( 0-da ) / ( db - da );
+00059         return p0 + (p1-p0)*decal;
+00060 }
+
+

+ + + + +
+ + + + + + + + + +
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. +

+

00161 {
+00162         a = -a;
+00163         b = -b;
+00164         c = -c;
+00165         d = -d;
+00166 }
+
+

+ + + + +
+ + + + + + + + + +
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. +

+

00155 {
+00156         return CPlane(-a, -b, -c, -d);
+00157 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
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. +

+

00045 {
+00046         CVector v;
+00047 
+00048         v=(p1-p0)^(p2-p1);
+00049         make(v,p1);
+00050 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
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, NLMISC::CVector::normed(), and v. +

+Referenced by NL3D::CMiniCol::addFaces(), NL3D::CCameraCol::build(), NL3D::CZoneLighter::buildZoneInformation(), NL3D::CBSPTree< T >::CBSPNode::CBSPNode(), NL3D::CPortal::clipRay(), NL3D::CWaterModel::computeClippedPoly(), NLPACS::CLocalRetriever::getHeight(), NLSOUND::CClusteredSound::getPolyNearestPos(), NL3D::CCubeGrid< TCell >::insert(), NLMISC::CPolygon2D::isConvex(), NL3D::CZoneLighter::light(), NL3D::CInstanceLighter::light(), make(), NLMISC::CAABBox::makePyramid(), NL3D::CCluster::makeVolume(), NL3D::CCameraCol::minimizeDistanceAgainstTri(), NL3D::CEvent3dMouseListener::operator()(), NL3D::CHeatHaze::performHeatHaze(), NL3D::CPSZoneRectangle::performMotion(), NL3D::CPSZoneDisc::performMotion(), NL3D::CPSZonePlane::performMotion(), NL3D::CCubeGrid< TCell >::select(), NL3D::CQuadTree< T >::selectRay(), NL3D::CQuadTree< T >::selectSegment(), NL3D::CPortal::setPoly(), NLPACS::CLocalRetriever::snapToInteriorGround(), NLMISC::CPolygon::toConvexPolygonsLocalAndBSP(), and NL3D::CVisualCollisionEntity::triangleIntersect(). +

+

00037 {
+00038         CVector v= normal.normed();
+00039         a= v.x;
+00040         b= v.y;
+00041         c= v.z;
+00042         d=-(v*p);               // d=- (ax+by+cz).
+00043 }
+
+

+ + + + +
+ + + + + + + + + +
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, getNormal(), and NLMISC::CVector::norm(). +

+Referenced by NL3D::CBSPTree< T >::CBSPNode::CBSPNode(), NL3D::CMeshMRMSkinnedGeom::clip(), NL3D::CMeshMRMGeom::clip(), NL3D::CMeshGeom::clip(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CCluster::makeVolume(), normed(), and NL3D::CPortal::setPoly(). +

+

00069 {
+00070         float   n= getNormal().norm();
+00071         if(n)
+00072         {
+00073                 float   oon= 1.0f/n;
+00074                 a*= oon;
+00075                 b*= oon;
+00076                 c*= oon;
+00077                 d*= oon;
+00078         }
+00079 }
+
+

+ + + + +
+ + + + + + + + + +
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 normalize(). +

+Referenced by distance(). +

+

00082 {
+00083         CPlane  ret= *this;
+00084         ret.normalize();
+00085         return ret;
+00086 }
+
+

+ + + + +
+ + + + + + + + + + +
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, d, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+

00047 {
+00048         return a*p.x + b*p.y + c*p.z + d;
+00049 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLMISC::CPlane::operator== const CPlane o  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 161 of file plane.h. +

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

+

00162         {
+00163                 return a==o.a && b==o.b && c==o.c && d==o.d;
+00164         }
+
+

+ + + + +
+ + + + + + + + + + +
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(). +

+Referenced by NL3D::CInstanceGroup::displayDebugClusters(), and NLSOUND::CClusteredSound::getPolyNearestPos(). +

+

00063 {
+00064         return intersect(p0, p0+getNormal());
+00065 }
+
+

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

+ +

+Definition at line 155 of file plane.h. +

+References a, b, c, d, and NLMISC::IStream::serial(). +

+

00156         {
+00157                 f.serial(a,b,c,d);
+00158         }
+
+


Field Documentation

+

+ + + + +
+ + +
float NLMISC::CPlane::a +
+
+ + + + + +
+   + + +

+ +

+Definition at line 52 of file plane.h. +

+Referenced by CPlane(), getNormal(), invert(), inverted(), make(), normalize(), operator *(), NLMISC::operator *(), operator==(), NL3D::CHeatHaze::performHeatHaze(), and serial().

+

+ + + + +
+ + +
float NLMISC::CPlane::b +
+
+ + + + + +
+   + + +

+ +

+Definition at line 52 of file plane.h. +

+Referenced by CPlane(), getNormal(), invert(), inverted(), make(), normalize(), operator *(), NLMISC::operator *(), operator==(), and serial().

+

+ + + + +
+ + +
float NLMISC::CPlane::c +
+
+ + + + + +
+   + + +

+ +

+Definition at line 52 of file plane.h. +

+Referenced by CPlane(), getNormal(), invert(), inverted(), make(), normalize(), operator *(), NLMISC::operator *(), operator==(), NL3D::CHeatHaze::performHeatHaze(), and serial().

+

+ + + + +
+ + +
float NLMISC::CPlane::d +
+
+ + + + + +
+   + + +

+ +

+Definition at line 52 of file plane.h. +

+Referenced by NL3D::CPortal::clipRay(), NL3D::CWaterModel::computeClippedPoly(), CPlane(), invert(), inverted(), make(), NL3D::CCameraCol::minimizeDistanceAgainstTri(), normalize(), operator *(), NLMISC::operator *(), operator==(), NL3D::CHeatHaze::performHeatHaze(), and serial().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 13:27:45 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1