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