BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Cartesian/Translation_rep_2.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/Translation_rep_2.h $
00019 // $Id: Translation_rep_2.h 28567 2006-02-16 14:30:13Z lsaboret $
00020 // 
00021 //
00022 // Author(s)     : Andreas Fabri, Herve Bronnimann
00023 
00024 #ifndef CGAL_CARTESIAN_TRANSLATION_REP_2_H
00025 #define CGAL_CARTESIAN_TRANSLATION_REP_2_H
00026 
00027 CGAL_BEGIN_NAMESPACE
00028 
00029 template < class R >
00030 class Translation_repC2 : public Aff_transformation_rep_baseC2<R>
00031 {
00032 friend class Aff_transformation_repC2<R>;
00033 friend class Rotation_repC2<R>;
00034 friend class Scaling_repC2<R>;
00035 
00036 public:
00037   typedef typename R::FT                         FT;
00038   typedef Aff_transformation_rep_baseC2<R>       Aff_t_base;
00039   typedef Aff_transformation_repC2<R>            Transformation;
00040   typedef Translation_repC2<R>                   Translation;
00041   typedef Rotation_repC2<R>                      Rotation;
00042   typedef Scaling_repC2<R>                       Scaling;
00043   typedef typename Aff_t_base::Point_2           Point_2;
00044   typedef typename Aff_t_base::Vector_2          Vector_2;
00045   typedef typename Aff_t_base::Direction_2       Direction_2;
00046   typedef typename Aff_t_base::Aff_transformation_2 Aff_transformation_2;
00047 
00048 
00049   Translation_repC2() {}
00050 
00051   Translation_repC2(const Vector_2 &tv)
00052     : translationvector_(tv)
00053   {}
00054 
00055   Point_2     transform(const Point_2 &p) const
00056   { 
00057     typename R::Construct_translated_point_2 translated_point;
00058     return translated_point(p, translationvector_); 
00059   }
00060 
00061   Vector_2    transform(const Vector_2 &v) const { return v; }
00062   Direction_2 transform(const Direction_2 &d) const { return d; }
00063 
00064   Aff_transformation_2 operator*(const Aff_t_base &t) const
00065   {
00066     return t.compose(*this);
00067   }
00068 
00069   Aff_transformation_2 compose(const Translation &t) const
00070   {
00071     return Aff_transformation_2(TRANSLATION,
00072                                 translationvector_ + t.translationvector_);
00073   }
00074 
00075   Aff_transformation_2 compose(const Rotation &t) const
00076   {
00077     return Aff_transformation_2(t.cosinus_,
00078                                 -t.sinus_,
00079                                 t.cosinus_*translationvector_.x() -
00080                                 t.sinus_*translationvector_.y(),
00081 
00082                                 t.sinus_,
00083                                 t.cosinus_,
00084                                 t.sinus_*translationvector_.x() +
00085                                 t.cosinus_*translationvector_.y());
00086   }
00087 
00088   Aff_transformation_2 compose(const Scaling &t) const
00089   {
00090     return Aff_transformation_2(t.scalefactor_,
00091                                 FT(0),
00092                                 t.scalefactor_*translationvector_.x(),
00093 
00094                                 FT(0),
00095                                 t.scalefactor_,
00096                                 t.scalefactor_*translationvector_.y());
00097   }
00098 
00099   Aff_transformation_2 compose(const Transformation &t) const
00100   {
00101     return Aff_transformation_2(t.t11,
00102                                 t.t12,
00103                                 t.t11 * translationvector_.x()
00104                                 + t.t12 * translationvector_.y()
00105                                 + t.t13,
00106 
00107                                 t.t21,
00108                                 t.t22,
00109                                 t.t21 * translationvector_.x()
00110                                 + t.t22*translationvector_.y()
00111                                 + t.t23);
00112   }
00113 
00114   Aff_transformation_2 inverse() const
00115   {
00116     return Aff_transformation_2(TRANSLATION, - translationvector_);
00117   }
00118 
00119   bool         is_even() const
00120   {
00121     return true;
00122   }
00123 
00124   FT cartesian(int i, int j) const
00125   {
00126     if (j==i) return FT(1);
00127     if (j==2) return translationvector_[i];
00128     return FT(0);
00129   }
00130 
00131   std::ostream &print(std::ostream &os) const
00132   {
00133     os << "Aff_transformationC2(VectorC2(" << translationvector_.x() << ", "
00134        << translationvector_.y()  <<  "))";
00135     return os;
00136   }
00137 
00138 private:
00139   Vector_2   translationvector_;
00140 };
00141 
00142 CGAL_END_NAMESPACE
00143 
00144 #endif // CGAL_CARTESIAN_TRANSLATION_REP_2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines