BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Cartesian/Aff_transformation_3.h
Go to the documentation of this file.
00001 // Copyright (c) 2000  Utrecht University (The Netherlands),
00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
00005 // and Tel-Aviv University (Israel).  All rights reserved.
00006 //
00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License as
00009 // published by the Free Software Foundation; version 2.1 of the License.
00010 // See the file LICENSE.LGPL distributed with CGAL.
00011 //
00012 // Licensees holding a valid commercial license may use this file in
00013 // accordance with the commercial license agreement provided with the software.
00014 //
00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 //
00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h $
00019 // $Id: Aff_transformation_3.h 32871 2006-08-01 12:09:47Z spion $
00020 // 
00021 //
00022 // Author(s)     : Andreas Fabri
00023 
00024 #ifndef CGAL_CARTESIAN_AFF_TRANSFORMATION_3_H
00025 #define CGAL_CARTESIAN_AFF_TRANSFORMATION_3_H
00026 
00027 #include <cmath>
00028 #include <CGAL/Handle_for_virtual.h>
00029 
00030 CGAL_BEGIN_NAMESPACE
00031 
00032 class Identity_transformation;
00033 template <class R> class Aff_transformation_rep_baseC3;
00034 template <class R> class Aff_transformation_repC3;
00035 template <class R> class Translation_repC3;
00036 template <class R> class Scaling_repC3;
00037 
00038 CGAL_END_NAMESPACE
00039 
00040 #include <CGAL/Cartesian/Aff_transformation_rep_3.h>
00041 #include <CGAL/Cartesian/Translation_rep_3.h>
00042 #include <CGAL/Cartesian/Scaling_rep_3.h>
00043 
00044 CGAL_BEGIN_NAMESPACE
00045 
00046 template < class R_ >
00047 class Aff_transformationC3
00048   : public Handle_for_virtual<Aff_transformation_rep_baseC3<R_> >
00049 {
00050   friend class PlaneC3<R_>; // FIXME: why ?
00051 
00052   typedef typename R_::FT                   FT;
00053   typedef Aff_transformation_rep_baseC3<R_> Aff_t_base;
00054 
00055   typedef typename R_::Point_3              Point_3;
00056   typedef typename R_::Vector_3             Vector_3;
00057   typedef typename R_::Direction_3          Direction_3;
00058   typedef typename R_::Plane_3              Plane_3;
00059   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00060 public:
00061   typedef R_                               R;
00062 
00063   Aff_transformationC3()
00064   {
00065     FT ft1(1), ft0(0);
00066     initialize_with(Aff_transformation_repC3<R>(ft1, ft0, ft0,
00067                                           ft0, ft1, ft0,
00068                                           ft0, ft0, ft1));
00069   }
00070 
00071   Aff_transformationC3(const Identity_transformation)
00072   {
00073     FT ft1(1), ft0(0);
00074     initialize_with(Aff_transformation_repC3<R>(ft1, ft0, ft0,
00075                                           ft0, ft1, ft0,
00076                                           ft0, ft0, ft1));
00077   }
00078 
00079   Aff_transformationC3(const Translation, const Vector_3 &v)
00080   {
00081     initialize_with(Translation_repC3<R>(v));
00082   }
00083 
00084   Aff_transformationC3(const Scaling, const FT &s, const FT &w = FT(1))
00085   {
00086     if (w != FT(1))
00087       initialize_with(Scaling_repC3<R>(s/w));
00088     else
00089       initialize_with(Scaling_repC3<R>(s));
00090   }
00091 
00092   // General form: without translation
00093   Aff_transformationC3(const FT& m11, const FT& m12, const FT& m13,
00094                        const FT& m21, const FT& m22, const FT& m23,
00095                        const FT& m31, const FT& m32, const FT& m33,
00096                        const FT& w = FT(1))
00097   {
00098     if (w != FT(1))
00099       initialize_with(Aff_transformation_repC3<R>(m11/w, m12/w, m13/w,
00100                                             m21/w, m22/w, m23/w,
00101                                             m31/w, m32/w, m33/w));
00102     else
00103       initialize_with(Aff_transformation_repC3<R>(m11, m12, m13,
00104                                             m21, m22, m23,
00105                                             m31, m32, m33));
00106   }
00107 
00108   // General form: with translation
00109   Aff_transformationC3(
00110               const FT& m11, const FT& m12, const FT& m13, const FT& m14,
00111               const FT& m21, const FT& m22, const FT& m23, const FT& m24,
00112               const FT& m31, const FT& m32, const FT& m33, const FT& m34,
00113               const FT& w = FT(1))
00114   {
00115     if (w != FT(1))
00116       initialize_with(Aff_transformation_repC3<R>(m11/w, m12/w, m13/w, m14/w,
00117                                             m21/w, m22/w, m23/w, m24/w,
00118                                             m31/w, m32/w, m33/w, m34/w));
00119     else
00120       initialize_with(Aff_transformation_repC3<R>(m11, m12, m13, m14,
00121                                             m21, m22, m23, m24,
00122                                             m31, m32, m33, m34));
00123   }
00124 
00125   Point_3
00126   transform(const Point_3 &p) const
00127   { return this->Ptr()->transform(p); }
00128 
00129   Point_3
00130   operator()(const Point_3 &p) const
00131   { return transform(p); }
00132 
00133   Vector_3
00134   transform(const Vector_3 &v) const
00135   { return this->Ptr()->transform(v); }
00136 
00137   Vector_3
00138   operator()(const Vector_3 &v) const
00139   { return transform(v); }
00140 
00141   Direction_3
00142   transform(const Direction_3 &d) const
00143   { return this->Ptr()->transform(d); }
00144 
00145   Direction_3
00146   operator()(const Direction_3 &d) const
00147   { return transform(d); }
00148 
00149   Plane_3
00150   transform(const Plane_3& p) const
00151   {
00152     if (is_even())
00153       return Plane_3(transform(p.point()),
00154                  transpose().inverse().transform(p.orthogonal_direction()));
00155     else
00156       return Plane_3(transform(p.point()),
00157                - transpose().inverse().transform(p.orthogonal_direction()));
00158   }
00159 
00160   Plane_3
00161   operator()(const Plane_3& p) const
00162   { return transform(p); } // FIXME : not compiled by the test-suite !
00163 
00164   Aff_transformation_3 inverse() const { return this->Ptr()->inverse(); }
00165   
00166   bool is_even() const { return this->Ptr()->is_even(); }
00167   bool is_odd() const { return  ! (this->Ptr()->is_even()); }
00168   
00169   FT cartesian(int i, int j) const { return this->Ptr()->cartesian(i,j); }
00170   FT homogeneous(int i, int j) const { return cartesian(i,j); }
00171   FT m(int i, int j) const { return cartesian(i,j); }
00172   FT hm(int i, int j) const { return cartesian(i,j); }
00173 
00174   Aff_transformation_3 operator*(const Aff_transformationC3 &t) const
00175   { return (*this->Ptr()) * (*t.Ptr()); }
00176 
00177 protected:
00178   Aff_transformation_3  transpose() const { return this->Ptr()->transpose(); }
00179 };
00180 
00181 
00182 #ifndef CGAL_NO_OSTREAM_INSERT_AFF_TRANSFORMATIONC3
00183 template < class R >
00184 std::ostream &operator<<(std::ostream &os,
00185                          const Aff_transformationC3<R> &t)
00186 {
00187     t.print(os);
00188     return os;
00189 }
00190 #endif // CGAL_NO_OSTREAM_INSERT_AFF_TRANSFORMATIONC3
00191 
00192 CGAL_END_NAMESPACE
00193 
00194 #endif // CGAL_CARTESIAN_AFF_TRANSFORMATION_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines