"Fossies" - the Fresh Open Source Software Archive

Member "aqsis-1.8.2/libs/core/plane.h" (24 Aug 2012, 1905 Bytes) of package /linux/privat/aqsis-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Aqsis
    2 // Copyright (C) 1997 - 2001, Paul C. Gregory
    3 //
    4 // Contact: pgregory@aqsis.org
    5 //
    6 // This library is free software; you can redistribute it and/or
    7 // modify it under the terms of the GNU General Public
    8 // License as published by the Free Software Foundation; either
    9 // version 2 of the License, or (at your option) any later version.
   10 //
   11 // This library is distributed in the hope that it will be useful,
   12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14 // General Public License for more details.
   15 //
   16 // You should have received a copy of the GNU General Public
   17 // License along with this library; if not, write to the Free Software
   18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19 
   20 
   21 /** \file
   22         \brief Declares a simple class representing an infinite plane.
   23         \author Paul C. Gregory (pgregory@aqsis.org)
   24 */
   25 
   26 //? Is .h included already?
   27 #ifndef PLANE_H_INCLUDED
   28 #define PLANE_H_INCLUDED
   29 
   30 #include    <aqsis/aqsis.h>
   31 #include    <aqsis/math/vector3d.h>
   32 
   33 namespace Aqsis {
   34 
   35 class CqPlane
   36 {
   37     public:
   38         CqPlane(const CqVector3D& point, const CqVector3D& normal)
   39         {
   40             m_a = normal.x();
   41             m_b = normal.y();
   42             m_c = normal.z();
   43             m_d = -(normal*point);
   44         }
   45 
   46         CqPlane(TqFloat a, TqFloat b, TqFloat c, TqFloat d)
   47         {
   48             m_a = a;
   49             m_b = b;
   50             m_c = c;
   51             m_d = d;
   52         }
   53         ~CqPlane()
   54         {}
   55 
   56         enum EqHalfSpace
   57         {
   58             Space_Negative = -1,
   59             Space_On_Plane = 0,
   60             Space_Positive = 1,
   61     };
   62 
   63 
   64         EqHalfSpace whichSide(const CqVector3D& p) const
   65         {
   66             TqFloat d = m_a*p.x() + m_b*p.y() + m_c*p.z() + m_d;
   67             if(d < 0)
   68                 return(Space_Negative);
   69             if(d > 0)
   70                 return(Space_Positive);
   71             return(Space_On_Plane);
   72         }
   73 
   74     private:
   75         TqFloat m_a, m_b, m_c, m_d;
   76 };
   77 
   78 //-----------------------------------------------------------------------
   79 
   80 } // namespace Aqsis
   81 
   82 #endif  // !PLANE_H_INCLUDED