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: create matrix M = a * b^T
00052     static GeMatrix3 outerProduct( const GeVector& a, const GeVector& b );
00053 
00054     // ----- member functions -----
00055     
00056     GeMatrix3();
00057     GeMatrix3(
00058         Float entry00, Float entry01, Float entry02,
00059         Float entry10, Float entry11, Float entry12,
00060         Float entry20, Float entry21, Float entry22
00061     );
00062     // Default copy constructor is fine.
00063     
00064     // Default assignment operator is fine.
00065     Float operator()( UInt32 row, UInt32 col ) const;
00066     Float& operator()( UInt32 row, UInt32 col );
00067     GeMatrix3& operator*=( const GeMatrix3& );
00068     GeMatrix3& operator*=( Float );
00069     GeMatrix3& operator+=( const GeMatrix3& );
00070     GeMatrix3& operator-=( const GeMatrix3& );
00071     GeMatrix3 operator*( const GeMatrix3& ) const;
00072 
00073     GeVector operator*( const GeVector& ) const;
00074     GePoint operator*( const GePoint& ) const;
00075 
00076     GeMatrix3 operator*( Float ) const;
00077     GeMatrix3 operator+( const GeMatrix3& ) const;
00078     GeMatrix3 operator-( const GeMatrix3& ) const;
00079     bool operator==( const GeMatrix3& ) const;
00080     bool operator!=( const GeMatrix3& ) const;
00081 
00082     //! Sum of diagonal elements.
00083     Float getTrace() const;
00084     //! Not the standard definition... max of all elements
00085     Float infinityNorm() const;
00086     //! Retrieve data as a flat array, column-major storage
00087     const Float* asColMajor() const;
00088     GeMatrix3 getTranspose() const;
00089     GeMatrix3 getInverse() const;
00090 
00091     // ----- static data members -----
00092     static const GeMatrix3 ZERO;
00093     static const GeMatrix3 IDENTITY;
00094 
00095 private:
00096     // ----- static data members -----
00097 
00098     //! Stored in column-major format.
00099     Float _data[ 9 ];
00100 };
00101 
00102 
00103 ////////////////////////////////////////////////////////////////////////////////
00104 // GLOBAL FUNCTIONS
00105 //
00106 
00107 //! Debug output.
00108 std::ostream& operator<<( std::ostream&, const GeMatrix3& );
00109 //! Scalar-matrix multiplication
00110 GeMatrix3 operator*( Float, const GeMatrix3& );
00111 //! Multiply row vector by matrix, v^T * M
00112 GeVector operator*( const GeVector&, const GeMatrix3& );
00113 
00114 FREECLOTH_NAMESPACE_END
00115 
00116 #include <freecloth/geom/geMatrix3.inline.h>
00117 
00118 #endif

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