HyperspaceExplorer 0.7.1
Rotation.h
00001 /*
00002     Hyperspace Explorer - vizualizing higher-dimensional geometry
00003     Copyright (C) 2010  Lene Preuss <lene.preuss@gmail.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later 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 General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License along
00016     with this program; if not, write to the Free Software Foundation, Inc.,
00017     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018 
00019 */
00020 #ifndef VECMATHROTATION_H
00021 #define VECMATHROTATION_H
00022 
00023 #include "Vector.h"
00024 #include "Matrix.h"
00025 #include "NotYetImplementedException.h"
00026 #include "Util.h"
00027 
00028 namespace VecMath {
00029 
00031 
00035     template <unsigned D> struct NumAxes {
00036         enum { num = NumAxes<D-1>::num+D-1 };
00037     };
00039     template <> struct NumAxes<0> { enum { num = 0 }; };
00041     template <> struct NumAxes<1> { enum { num = 0 }; };
00042 
00044 
00058     template <unsigned D> class RotationAxes {
00059         public:
00060             static unsigned axis(unsigned which, unsigned index);
00061         private:
00063             static unsigned _axis[2][NumAxes<D>::num];
00064     };
00065 
00067     template <> class RotationAxes<3> {
00068         public:
00069             static unsigned axis(unsigned which, unsigned index);
00070         private:
00071             static const unsigned _axis[2][3];  
00072     };
00073 
00075     template <> class RotationAxes<4> {
00076         public:
00077             static unsigned axis(unsigned which, unsigned index);
00078         private:
00079             static const unsigned _axis[2][6];  
00080     };
00081 
00083 
00086     class RotationBase { };
00087 
00089 
00093     template <unsigned D, typename N = double> class Rotation:
00094             public RotationBase {
00095 
00096         public:
00097           
00099             Rotation<D, N>();
00100 
00102             Rotation<D, N> (N r0, ... );
00103 
00105             N &operator[] (unsigned i);
00107             N operator[] (unsigned i) const;
00108 
00110             operator Matrix<D, N>() const;
00111 
00113             Rotation<D, N> &operator+= (const Rotation<D, N> &that);
00114 
00116             operator bool() const;
00117 
00119             const Vector<NumAxes<D>::num, N> &r() const;
00120 
00122             Vector<NumAxes<D>::num, N> &r();
00123 
00125             std::string toString() const;
00126 
00127         private:
00128           
00130             Vector<NumAxes<D>::num, N> axis;
00131     };
00132 
00133 
00134     //------------  important non-member functions for class Rotation
00135 
00137     template <unsigned D, typename N>
00138     Rotation<D, N> operator+ (const Rotation<D, N> &A, const Rotation<D, N> &B);
00139 
00141     std::ostream &operator << (std::ostream &o, const RotationBase &);
00142 
00144     template <unsigned D, typename N>
00145     std::ostream &operator << (std::ostream &o, const Rotation<D, N> &v);
00146 
00148     template <unsigned D, typename N>
00149     std::istringstream &operator >> (std::istringstream &in, Rotation<D, N> &v);
00150 
00151     //------------  functions that generate a Rotation without resorting to variable arglists
00152 
00154     template <typename N> 
00155     Rotation<3, N> makeRotation(N const &r0, N const &r1, N const &r2);
00156 
00158     template <typename N> 
00159     Rotation<4, N> makeRotation(N const &r0, N const &r1, N const &r2, 
00160                                 N const &r3, N const &r4, N const &r5);
00161 }
00162 
00163 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:16 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo