Main Page   Class Hierarchy   Compound List   File List   Compound Members  

geMatrix3.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2002-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_geMatrix3_h
00020 #define freecloth_geom_geMatrix3_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 class GePoint;
00033 
00034 ////////////////////////////////////////////////////////////////////////////////
00035 /*!
00036  * \class GeMatrix3 freecloth/geom/geMatrix3.h
00037  * \brief A simple 3x3 matrix class.
00038  */
00039 class GeMatrix3
00040 {
00041 public:
00042     // ----- static member functions -----
00043     
00044     //! Named constructor: construct from float array, column-major storage
00045     static GeMatrix3 colMajor( const Float data[ 9 ] );
00046     //! Named constructor: construct from float array, row-major storage
00047     static GeMatrix3 rowMajor( const Float data[ 9 ] );
00048     //! Named constructor: construct a scaling matrix, with [sx sy sz] along
00049     //! the main diagonal
00050     static GeMatrix3 scaling( Float sx, Float sy, Float sz );
00051     //! Named constructor: construct a rotation matrix, representing a
00052     //! rotation of theta about the given axis.
00053     static GeMatrix3 rotation( const GeVector& axis, Float theta );
00054     //! Named constructor: create matrix M = a * b^T
00055     static GeMatrix3 outerProduct( const GeVector& a, const GeVector& b );
00056 
00057     // ----- member functions -----
00058     
00059     GeMatrix3();
00060     GeMatrix3(
00061         Float entry00, Float entry01, Float entry02,
00062         Float entry10, Float entry11, Float entry12,
00063         Float entry20, Float entry21, Float entry22
00064     );
00065     // Default copy constructor is fine.
00066     
00067     // Default assignment operator is fine.
00068     Float operator()( UInt32 row, UInt32 col ) const;
00069     Float& operator()( UInt32 row, UInt32 col );
00070     GeMatrix3& operator*=( const GeMatrix3& );
00071     GeMatrix3& operator*=( Float );
00072     GeMatrix3& operator+=( const GeMatrix3& );
00073     GeMatrix3& operator-=( const GeMatrix3& );
00074     GeMatrix3 operator*( const GeMatrix3& ) const;
00075 
00076     GeVector operator*( const GeVector& ) const;
00077     GePoint operator*( const GePoint& ) const;
00078 
00079     GeMatrix3 operator*( Float ) const;
00080     GeMatrix3 operator+( const GeMatrix3& ) const;
00081     GeMatrix3 operator-( const GeMatrix3& ) const;
00082     bool operator==( const GeMatrix3& ) const;
00083     bool operator!=( const GeMatrix3& ) const;
00084 
00085     //! Sum of diagonal elements.
00086     Float getTrace() const;
00087     //! Not the standard definition... max of all elements
00088     Float infinityNorm() const;
00089     //! Retrieve data as a flat array, column-major storage
00090     const Float* asColMajor() const;
00091     GeMatrix3 getTranspose() const;
00092     GeMatrix3 getInverse() const;
00093 
00094     // ----- static data members -----
00095     static const GeMatrix3 ZERO;
00096     static const GeMatrix3 IDENTITY;
00097 
00098 private:
00099     // ----- static data members -----
00100 
00101     //! Stored in column-major format.
00102     Float _data[ 9 ];
00103 };
00104 
00105 
00106 ////////////////////////////////////////////////////////////////////////////////
00107 // GLOBAL FUNCTIONS
00108 //
00109 
00110 //! Debug output.
00111 std::ostream& operator<<( std::ostream&, const GeMatrix3& );
00112 //! Scalar-matrix multiplication
00113 GeMatrix3 operator*( Float, const GeMatrix3& );
00114 //! Multiply row vector by matrix, v^T * M
00115 GeVector operator*( const GeVector&, const GeMatrix3& );
00116 
00117 FREECLOTH_NAMESPACE_END
00118 
00119 #include <freecloth/geom/geMatrix3.inline.h>
00120 
00121 #endif

Generated on Fri May 2 16:51:12 2003 for Freecloth by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002