Main Page   Class Hierarchy   Compound List   File List   Compound Members  

simVector.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 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_sim_simVector_h
00020 #define freecloth_sim_simVector_h
00021 
00022 #ifndef freecloth_simulator_package_h
00023 #include <freecloth/simulator/package.h>
00024 #endif
00025 
00026 #ifndef freecloth_geom_geVector_h
00027 #include <freecloth/geom/geVector.h>
00028 #endif
00029 
00030 #ifndef freecloth_base_vector
00031 #include <freecloth/base/vector>
00032 #endif
00033 
00034 FREECLOTH_NAMESPACE_START
00035 
00036 ////////////////////////////////////////////////////////////////////////////////
00037 // FORWARD DECLARATIONS
00038 
00039 ////////////////////////////////////////////////////////////////////////////////
00040 /*!
00041  * \class SimVector freecloth/simulator/simVector.h
00042  * \brief Dense vector class.
00043  *
00044  * Uses 3x1 GeVector objects as the contents of the vector.
00045  *
00046  * This implements the bare minimum necessary for the cloth simulation,
00047  * and is not really intended as a general purpose dense vector class.
00048  *
00049  * See SimMatrix for a discussion of other matrix libraries.
00050  */
00051 class SimVector {
00052 
00053 public:
00054 
00055     // ----- types and enumerations -----
00056     typedef std::vector<GeVector> Container;
00057     typedef Container::const_iterator const_iterator;
00058     typedef Container::iterator iterator;
00059 
00060     // ----- static member functions -----
00061     // named constructor
00062     static SimVector zero( UInt32 size );
00063 
00064     // ----- member functions -----
00065     SimVector();
00066     explicit SimVector( UInt32 size );
00067     // Default copy constructor is fine.
00068 
00069     const_iterator begin() const;
00070     const_iterator end() const;
00071     iterator begin();
00072     iterator end();
00073 
00074     UInt32 size() const;
00075 
00076     // Default assignment operator is fine.
00077     SimVector& operator+=( const SimVector& );
00078     SimVector& operator-=( const SimVector& );
00079     SimVector& operator+=( Float );
00080     SimVector& operator-=( Float );
00081     SimVector& operator*=( Float );
00082     SimVector& operator/=( Float );
00083     SimVector operator-() const;
00084     SimVector operator+( const SimVector& ) const;
00085     SimVector operator-( const SimVector& ) const;
00086     SimVector operator+( Float ) const;
00087     SimVector operator-( Float ) const;
00088     SimVector operator*( Float ) const;
00089     SimVector operator/( Float ) const;
00090 
00091     //! A combined operator, saving the overhead of constructing a temporary:
00092     //!   *this += scalar * vec
00093     //! We don't have expression templates, so this is the best alternative.
00094     SimVector& plusEqualsScaled( Float, const SimVector& );
00095 
00096     Float dot( const SimVector& ) const;
00097     Float length() const;
00098 
00099     const GeVector& operator[]( UInt32 ) const;
00100     GeVector& operator[]( UInt32 );
00101 
00102     // Set to zero
00103     void clear();
00104 
00105 private:
00106 
00107     // ----- data members -----
00108 
00109     Container _data;
00110 };
00111 
00112 ////////////////////////////////////////////////////////////////////////////////
00113 // GLOBAL FUNCTIONS
00114 //
00115 std::ostream& operator<<( std::ostream&, const SimVector& );
00116 SimVector operator*( Float, SimVector const& );
00117 
00118 FREECLOTH_NAMESPACE_END
00119 
00120 #include <freecloth/simulator/simVector.inline.h>
00121 
00122 #endif

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