Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OSGPlane.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000,2001 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef OSGPLANE_CLASS_DECLARATION
00040 #define OSGPLANE_CLASS_DECLARATION
00041 
00042 #include <OSGBaseTypes.h>
00043 #include <OSGBaseFunctions.h>
00044 
00045 #include "OSGVector.h"
00046 #include "OSGMatrix.h"
00047 
00048 OSG_BEGIN_NAMESPACE
00049 
00050 class Line;
00051 
00052 #ifdef WIN32 // Workaround for a bug in Visual C++ 6.0
00053 class Plane;
00054 OSG_BASE_DLLMAPPING
00055 bool operator ==(const Plane &p1, const Plane &p2);
00056 OSG_BASE_DLLMAPPING
00057 bool operator !=(const Plane &p1, const Plane &p2);
00058 #endif
00059 
00060 
00080 class OSG_BASE_DLLMAPPING Plane {
00081 
00082     /*==========================  PUBLIC  =================================*/
00083   public:
00084 
00085     /*---------------------------------------------------------------------*/
00089     Plane(void);
00090     Plane(const Plane &obj);
00091     Plane(const Pnt3f &p0, const Pnt3f &p1, const Pnt3f &p2);
00092     Plane(const Vec3f &n, Real32 d);
00093     Plane(const Vec3f &n, const Pnt3f &p);
00094 
00096     /*---------------------------------------------------------------------*/
00100     void offset(Real32 d);
00101 
00103     /*---------------------------------------------------------------------*/
00107     bool intersect         (const Plane &pl, Line &intersection) const;
00108 
00109     bool intersect         (const Line &l, Pnt3f &intersection)  const;
00110 
00111     bool intersect         (const Line &l, Real32 &t)            const;
00112 
00113     bool intersectInfinite (const Line &l, Real32 &t)            const;
00114 
00115     bool intersectInfinite (const Line &l, Pnt3f &intersection)  const;
00116 
00117 
00118     void   transform       (const Matrix &matrix);
00119 
00120     bool   isInHalfSpace   (const Pnt3f &point)                  const;
00121 
00122     bool   isOnPlane       (const Pnt3f &point)                  const;
00123 
00124     Real32 distance        (const Pnt3f &point)                  const;
00125 
00127     /*---------------------------------------------------------------------*/
00131     void set(const Vec3f &normal, Real32 distance);
00132     void set(Real32 x, Real32 y, Real32 z, Real32 distance);
00133     void set(const Vec4f &plane);
00134 
00136     /*---------------------------------------------------------------------*/
00140     inline const Vec3f  &getNormal             (void) const;
00141     inline       Real32  getDistanceFromOrigin (void) const;
00142 
00144     /*---------------------------------------------------------------------*/
00148     OSG_BASE_DLLMAPPING
00149     friend bool operator ==(const Plane &p1, const Plane &p2);
00150 
00151     inline OSG_BASE_DLLMAPPING
00152     friend bool operator !=(const Plane &p1, const Plane &p2);
00153 
00155     /*==========================  PRIVATE  ================================*/
00156   private:
00157 
00158     Vec3f _normalVec;
00159 
00160     Real32 _distance;
00161 
00162 };
00163 
00164 OSG_BASE_DLLMAPPING ostream &operator <<(ostream &os, const Plane &obj);
00165 
00166 OSG_END_NAMESPACE
00167 
00168 #include "OSGPlane.inl"
00169 
00170 #endif // OSGPLANE_CLASS_DECLARATION

Generated on Wed Jul 3 14:39:15 2002 for OpenSG by doxygen1.2.16