BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Cartesian/Translation_rep_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/Translation_rep_3.h $
00019 // $Id: Translation_rep_3.h 28567 2006-02-16 14:30:13Z lsaboret $
00020 // 
00021 //
00022 // Author(s)     : Herve Bronnimann
00023 
00024 #ifndef CGAL_CARTESIAN_TRANSLATION_REP_3_H
00025 #define CGAL_CARTESIAN_TRANSLATION_REP_3_H
00026 
00027 CGAL_BEGIN_NAMESPACE
00028 
00029 template < class R >
00030 class Translation_repC3 : public Aff_transformation_rep_baseC3<R>
00031 {
00032   friend class Aff_transformation_repC3<R>;
00033   friend class Scaling_repC3<R>;
00034 
00035 public:
00036   typedef typename R::FT                                FT;
00037   typedef Aff_transformation_rep_baseC3<R>              Transformation_base_3;
00038   typedef Aff_transformation_repC3<R>                   Transformation_3;
00039   typedef Translation_repC3<R>                          Translation_3;
00040   typedef Scaling_repC3<R>                              Scaling_3;
00041   typedef typename Transformation_base_3::Point_3       Point_3;
00042   typedef typename Transformation_base_3::Vector_3      Vector_3;
00043   typedef typename Transformation_base_3::Direction_3   Direction_3;
00044   typedef typename Transformation_base_3::Aff_transformation_3
00045                                                         Aff_transformation_3;
00046 
00047   Translation_repC3() {}
00048   Translation_repC3(const Vector_3 &tv) : translationvector_(tv) {}
00049   virtual ~Translation_repC3() {}
00050 
00051   virtual Point_3     transform(const Point_3 &p) const
00052   {
00053     return p + translationvector_;
00054   }
00055 
00056   virtual Vector_3    transform(const Vector_3 &v) const
00057   {
00058     return v;
00059   }
00060 
00061   virtual Direction_3 transform(const Direction_3 &d) const
00062   {
00063     return d;
00064   }
00065 
00066   virtual Aff_transformation_3 operator*(const Transformation_base_3 &t) const
00067   {
00068     return t.compose(*this);
00069   }
00070 
00071   virtual Aff_transformation_3 compose(const Transformation_3 &t) const
00072   {
00073     return Aff_transformation_3(t.t11,
00074                                 t.t12,
00075                                 t.t13,
00076                                 t.t11 * translationvector_.x()
00077                                 + t.t12 * translationvector_.y()
00078                                 + t.t13 * translationvector_.z() + t.t14,
00079                                 
00080                                 t.t21,
00081                                 t.t22,
00082                                 t.t23,
00083                                 t.t21 * translationvector_.x()
00084                                 + t.t22 * translationvector_.y()
00085                                 + t.t23 * translationvector_.z() + t.t24,
00086                                 
00087                                 t.t31,
00088                                 t.t32,
00089                                 t.t33,
00090                                 t.t31 * translationvector_.x()
00091                                 + t.t32 * translationvector_.y()
00092                                 + t.t33 * translationvector_.z() + t.t34);
00093   }
00094 
00095   virtual Aff_transformation_3 compose(const Translation_3 &t) const
00096   {
00097     return Aff_transformation_3(TRANSLATION,
00098                                 translationvector_ + t.translationvector_);
00099   }
00100 
00101   virtual Aff_transformation_3 compose(const Scaling_3 &t) const
00102   {
00103     FT ft0(0);
00104     return Aff_transformation_3(t.scalefactor_,
00105                                 ft0,
00106                                 ft0,
00107                                 t.scalefactor_ * translationvector_.x(),
00108                                 
00109                                 ft0,
00110                                 t.scalefactor_,
00111                                 ft0,
00112                                 t.scalefactor_ * translationvector_.y(),
00113                                 
00114                                 ft0,
00115                                 ft0,
00116                                 t.scalefactor_,
00117                                 t.scalefactor_ * translationvector_.z());
00118   }
00119 
00120   virtual Aff_transformation_3 inverse() const
00121   {
00122     return Aff_transformation_3(TRANSLATION, - translationvector_);
00123   }
00124 
00125   virtual Aff_transformation_3 transpose() const
00126   {
00127     return Aff_transformation_3(TRANSLATION, translationvector_);
00128   }
00129   
00130   virtual bool is_even() const
00131   {
00132     return true;
00133   }
00134 
00135   virtual FT cartesian(int i, int j) const
00136   {
00137     if (j==i) return FT(1);
00138     if (j==3) return translationvector_[i];
00139     return FT(0);
00140   }
00141 
00142   virtual std::ostream &print(std::ostream &os) const
00143   {
00144     os << "Aff_transformationC3(VectorC3("<< translationvector_.x() << ","
00145        << translationvector_.y() << ","
00146        << translationvector_.z() << "))\n";
00147     return os;
00148   }
00149 
00150 private:
00151   Vector_3   translationvector_;
00152 };
00153 
00154 CGAL_END_NAMESPACE
00155 
00156 #endif // CGAL_CARTESIAN_TRANSLATION_REP_3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines