Main Page   Class Hierarchy   Compound List   File List   Compound Members  

gePoint.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2003 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #ifndef freecloth_geom_gePoint_h
00020 #define freecloth_geom_gePoint_h
00021 
00022 #ifndef freecloth_geom_package_h
00023 #include <freecloth/geom/package.h>
00024 #endif
00025 
00026 FREECLOTH_NAMESPACE_START
00027 
00028 ////////////////////////////////////////////////////////////////////////////////
00029 // FORWARD DECLARATIONS
00030 
00031 class GeVector;
00032 
00033 ////////////////////////////////////////////////////////////////////////////////
00034 /*!
00035  * \class GePoint freecloth/geom/gePoint.h
00036  * \brief A class for 3D points.
00037  *
00038  * In keeping with the principles of affine spaces, we distinguish between
00039  * vectors and points, which represent direction and position, respectively.
00040  */
00041 class GePoint
00042 {
00043 public:
00044 
00045     // ----- classes -----
00046 
00047     //! Comparison functors for sorting or working with points
00048     //  TODO: add combined comparators that treat first one co-ord,
00049     //  then the other.
00050     class CompX {
00051     public:
00052         CompX() { }
00053         inline bool operator() ( const GePoint& a, const GePoint& b ) const
00054         { return a._x < b._x; }
00055     };
00056     //! Comparison functors for sorting or working with points
00057     class CompY {
00058     public:
00059         CompY() { }
00060         inline bool operator() ( const GePoint& a, const GePoint& b ) const
00061         { return a._y < b._y; }
00062     };
00063     //! Comparison functors for sorting or working with points
00064     class CompZ {
00065     public:
00066         CompZ() { }
00067         inline bool operator() ( const GePoint& a, const GePoint& b ) const
00068         { return a._z < b._z; }
00069     };
00070 
00071     // ----- member functions -----
00072     
00073     GePoint();
00074     GePoint( Float x, Float y, Float z );
00075     //! Construct from linear combination. Result = fracA * a + (1-fracA) * b
00076     GePoint( const GePoint& a, const GePoint& b, Float fracA );
00077     //! Construct from linear combination. fracA and fracB constitute two of
00078     //! three barycentric co-ordinates; (fracA,fracB,1-fracA-fracB) are the
00079     //! full three.
00080     GePoint(
00081         const GePoint& a, const GePoint& b, const GePoint& c,
00082         Float fracA, Float fracB
00083     );
00084     // Default copy constructor is fine.
00085 
00086     // Default assignment operator is fine.
00087     GePoint& operator+=( const GeVector& );
00088     GePoint& operator-=( const GeVector& );
00089     GePoint operator+( const GeVector& ) const;
00090     GePoint operator-( const GeVector& ) const;
00091     GeVector operator-( const GePoint& ) const;
00092     bool operator==( const GePoint& ) const;
00093     bool operator!=( const GePoint& ) const;
00094     Float operator[]( UInt32 ) const;
00095     Float& operator[]( UInt32 );
00096 
00097     // ----- static data members -----
00098 
00099     static const CompX _compX;
00100     static const CompY _compY;
00101     static const CompZ _compZ;
00102 
00103     static const GePoint NIL;
00104     static const GePoint ZERO;
00105 
00106     // ----- data members -----
00107 
00108     Float _x,_y,_z;
00109 };
00110 
00111 
00112 ////////////////////////////////////////////////////////////////////////////////
00113 // GLOBAL FUNCTIONS
00114 //
00115 std::ostream& operator<<( std::ostream&, const GePoint& );
00116 
00117 FREECLOTH_NAMESPACE_END
00118 
00119 #include <freecloth/geom/gePoint.inline.h>
00120 
00121 #endif

Generated on Wed Apr 23 15:58:46 2003 for Freecloth by doxygen1.3-rc3