glc_plane.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00023 
00024 #ifndef GLC_PLANE_H_
00025 #define GLC_PLANE_H_
00026 
00027 #include "glc_vector3d.h"
00028 
00029 #include "../glc_config.h"
00030 
00033 
00036 
00037 class GLC_LIB_EXPORT GLC_Plane
00038 {
00040 
00042 
00043 public:
00045         GLC_Plane();
00046 
00048 
00049         GLC_Plane(double A, double B, double C, double D);
00050 
00052         GLC_Plane(const GLC_Vector3d& normal, double minimumDistance);
00053 
00055         GLC_Plane(const GLC_Vector3d& normal, const GLC_Point3d& point);
00056 
00058 
00059         GLC_Plane(const GLC_Point3d&, const GLC_Point3d&, const GLC_Point3d&);
00060 
00062         GLC_Plane(const GLC_Plane&);
00063 
00065         GLC_Plane &operator=(const GLC_Plane&);
00066 
00068         ~GLC_Plane();
00070 
00072 
00074 
00075 public:
00076 
00078         inline double coefA() const
00079         {return m_Eq[0];}
00080 
00082         inline double coefB() const
00083         {return m_Eq[1];}
00084 
00086         inline double coefC() const
00087         {return m_Eq[2];}
00088 
00090         inline double coefD() const
00091         {return m_Eq[3];}
00092 
00094         inline double distanceToPoint(const GLC_Point3d& p) const
00095         {return m_Eq[0] * p.x() + m_Eq[1] * p.y() + m_Eq[2] * p.z() + m_Eq[3];}
00096 
00098         bool operator==(GLC_Plane) const;
00099 
00101         inline bool operator!=(const GLC_Plane& p) const
00102         {return !operator==(p);}
00103 
00105         inline GLC_Vector3d normal() const
00106         {return GLC_Vector3d(m_Eq[0], m_Eq[1], m_Eq[2]);}
00107 
00109         inline bool lieOnThisPlane(const GLC_Point3d& p)
00110         {return (m_Eq[0] * p.x() + m_Eq[1] * p.y() + m_Eq[2] * p.z() + m_Eq[3]) == 0.0f;}
00111 
00113         const double* data() const
00114         {return m_Eq;}
00115 
00117         QString toString() const;
00119 
00121 
00123 
00124 public:
00126         inline void setA(double a)
00127         {m_Eq[0]= a;}
00128 
00130         inline void setB(double b)
00131         {m_Eq[1]= b;}
00132 
00134         inline void setC(double c)
00135         {m_Eq[2]= c;}
00136 
00138         inline void setD(double d)
00139         {m_Eq[3]= d;}
00140 
00142         void normalize();
00143 
00145         GLC_Plane& setPlane(const GLC_Vector3d& normal, const GLC_Point3d& point);
00146 
00147 
00149 
00151 // Private Member
00153 private:
00155         double m_Eq[4];
00156 };
00157 
00158 #endif /* GLC_PLANE_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon