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