Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

Transform.hxx

00001 
00002 // 
00003 // Copyright (C) 2006 James M. Lawrence.  All rights reserved.
00004 // 
00005 // software: esve-1.0.3
00006 // file: esve/engine/dim3/impl/Transform.hxx
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions
00010 // are met:
00011 // 
00012 // 1. Redistributions of source code must retain the above copyright
00013 //    notice, this list of conditions and the following disclaimer.
00014 // 
00015 // 2. The origin of this software must not be misrepresented; you must
00016 //    not claim that you wrote the original software.  If you use this
00017 //    software in a product, an acknowledgment in the product 
00018 //    documentation would be appreciated but is not required.
00019 // 
00020 // 3. Altered source versions must be plainly marked as such, and must
00021 //    not be misrepresented as being the original software.
00022 // 
00023 // 4. The name of the author may not be used to endorse or promote
00024 //    products derived from this software without specific prior written
00025 //    permission.
00026 // 
00027 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY,
00028 // AND WITH NO CLAIM AS TO ITS SUITABILITY FOR ANY PURPOSE.  IN NO EVENT
00029 // SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM WHATSOEVER MADE IN CONNECTION
00030 // TO THIS SOFTWARE.
00031 // 
00033 #ifndef esve_engine_dim3_impl_Transform_hxx
00034 #define esve_engine_dim3_impl_Transform_hxx
00035 
00036 #include <esve/engine/dim3/Transform.hxx>
00037 #include <esve/base/dim3/Transform.hxx>
00038 #include <esve/types/quat.hxx>
00039 #include <esve/types/pure.hxx>
00040 
00041 namespace esve { namespace engine { namespace dim3 { namespace impl {
00042 
00047 
00048 class Transform
00049     : virtual public dim3::Transform
00050 {
00051 private:
00052     typedef
00053     base::dim3::Transform<types::real>
00054     m_Transform ;
00055 
00056     m_Transform m ;
00057 
00058 public:
00060     Transform()
00061         : dim3::Transform(),
00062           m() { }
00063 
00065     Transform( const types::quat & rotation,
00066                const types::pure & translation = types::pure(),
00067                types::real scaling = types::real(1) )
00068         : dim3::Transform(),
00069           m(rotation,
00070             translation,
00071             scaling) { }
00072 
00073     Transform( const Transform & a )
00074         : dim3::Transform(),
00075           m(a.m) { }
00076 
00077     Transform( const dim3::Transform & a )
00078         : dim3::Transform(),
00079           m(a.rotation(),
00080             a.translation(),
00081             a.scaling()) { }
00082 
00083     Transform & operator=( const Transform & a )
00084     {
00085         m = a.m ;
00086         return *this ;
00087     }
00088 
00089     Transform & operator=( const dim3::Transform & a )
00090     {
00091         m.rotation(a.rotation()) ;
00092         m.translation(a.translation()) ;
00093         m.scaling(a.scaling()) ;
00094         return *this ;
00095     }
00096 
00097     const types::quat & rotation() const
00098     {
00099         return m.rotation() ;
00100     }
00101 
00102     void rotation( const types::quat & a )
00103     {
00104         m.rotation(a) ;
00105     }
00106 
00107     const types::pure & translation() const
00108     {
00109         return m.translation() ;
00110     }
00111 
00112     void translation( const types::pure & a )
00113     {
00114         m.translation(a) ;
00115     }
00116 
00117     types::real scaling() const
00118     {
00119         return m.scaling() ;
00120     }
00121 
00122     void scaling( types::real a )
00123     {
00124         m.scaling(a) ;
00125     }
00126 
00127     void left_act( const Transform & a )
00128     {
00129         m.left_act(a.m) ;
00130     }
00131 
00132     void left_act( const dim3::Transform & a )
00133     {
00134         m.left_act(m_Transform(a.rotation(),
00135                                a.translation(),
00136                                a.scaling())) ;
00137     }
00138 
00139     void right_act( const Transform & a )
00140     {
00141         m.right_act(a.m) ;
00142     }
00143 
00144     void right_act( const dim3::Transform & a )
00145     {
00146         m.right_act(m_Transform(a.rotation(),
00147                                 a.translation(),
00148                                 a.scaling())) ;
00149     }
00150 
00151     void act( const Transform & action,
00152               const Transform & basis )
00153     {
00154         m.act(action.m, basis.m) ;
00155     }
00156 
00157     void act( const dim3::Transform & action,
00158               const dim3::Transform & basis )
00159     {
00160         m.act(m_Transform(action.rotation(),
00161                           action.translation(),
00162                           action.scaling()),
00163               m_Transform(basis.rotation(),
00164                           basis.translation(),
00165                           basis.scaling())) ;
00166     }
00167 
00168     void rotate( types::real angle,
00169                  const types::pure & axis,
00170                  const dim3::Transform & basis = IDENTITY ) ;
00171 
00172     void translate( const types::pure & dt,
00173                     const dim3::Transform & basis = IDENTITY ) ;
00174 
00175     void scalate( types::real ds,
00176                   const dim3::Transform & basis = IDENTITY ) ;
00177 
00178     void assign( const Transform & a )
00179     {
00180         m = a.m ;
00181     }
00182 
00183     void assign( const dim3::Transform & a )
00184     {
00185         rotation(a.rotation()) ;
00186         translation(a.translation()) ;
00187         scaling(a.scaling()) ;
00188     }
00189 
00190     void identity()
00191     {
00192         m.identity() ;
00193     }
00194 
00195     void invert()
00196     {
00197         m.invert() ;
00198     }
00199 
00200     void normalize()
00201     {
00202         m.normalize() ;
00203     }
00204 
00205     bool operator==( const Transform & a ) const
00206     {
00207         return m.operator==(a.m) ;
00208     }
00209 
00210     bool operator==( const dim3::Transform & a ) const
00211     {
00212         return m.operator==(m_Transform(a.rotation(),
00213                                         a.translation(),
00214                                         a.scaling())) ;
00215     }
00216     
00217     bool operator!=( const Transform & a ) const
00218     {
00219         return m.operator!=(a.m) ;
00220     }
00221 
00222     bool operator!=( const dim3::Transform & a ) const
00223     {
00224         return m.operator!=(m_Transform(a.rotation(),
00225                                         a.translation(),
00226                                         a.scaling())) ;
00227     }
00228 
00229     ~Transform() { }
00230 } ;
00231 
00232 }}}} // namespace esve::engine::dim3::impl
00233 
00234 #endif
00235 

Generated on Tue May 30 11:40:53 2006 for esve by doxygen 1.3.4