BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Homogeneous/Aff_transformationH2.h
Go to the documentation of this file.
00001 // Copyright (c) 1999  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/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h $
00019 // $Id: Aff_transformationH2.h 28567 2006-02-16 14:30:13Z lsaboret $
00020 // 
00021 //
00022 // Author(s)     : Stefan Schirra
00023 
00024 #ifndef CGAL_AFF_TRANSFORMATIONH2_H
00025 #define CGAL_AFF_TRANSFORMATIONH2_H
00026 
00027 #include <CGAL/Handle_for_virtual.h>
00028 #include <CGAL/rational_rotation.h>
00029 
00030 CGAL_BEGIN_NAMESPACE
00031 
00032 template <class R>
00033 class Aff_transformationH2;
00034 
00035 template <class R>
00036 class Aff_transformation_repH2;
00037 
00038 template <class R>
00039 Aff_transformationH2<R>
00040 _general_transformation_composition( Aff_transformation_repH2<R> l,
00041                                      Aff_transformation_repH2<R> r);
00042 
00043 template <class R>
00044 class Aff_transformation_rep_baseH2 : public Ref_counted_virtual
00045 {
00046   public:
00047     typedef typename R::RT RT;
00048     typedef typename R::FT FT;
00049     typedef typename R::Point_2      Point_2;
00050     typedef typename R::Vector_2     Vector_2;
00051     typedef typename R::Direction_2  Direction_2;
00052 
00053     virtual             ~Aff_transformation_rep_baseH2(){}
00054 
00055     virtual  Point_2
00056                         transform(const Point_2& p) const = 0;
00057     virtual  Vector_2
00058                         transform(const Vector_2& v) const = 0;
00059     virtual  Direction_2
00060                         transform(const Direction_2& d) const = 0;
00061     virtual  Aff_transformationH2<R>
00062                         inverse() const = 0;
00063     virtual  Aff_transformation_repH2<R>
00064                         general_form() const = 0;
00065     virtual  bool       is_even() const = 0;
00066 
00067     virtual  RT         homogeneous(int i, int j) const = 0;
00068     virtual  FT         cartesian(int i, int j) const = 0;
00069 };
00070 
00071 template < class R >
00072 class Aff_transformation_repH2 : public Aff_transformation_rep_baseH2<R>
00073 {
00074   public:
00075     typedef typename R::RT RT;
00076     typedef typename R::FT FT;
00077     typedef typename R::Point_2      Point_2;
00078     typedef typename R::Vector_2     Vector_2;
00079     typedef typename R::Direction_2  Direction_2;
00080 
00081     Aff_transformation_repH2()
00082     {}
00083 
00084     Aff_transformation_repH2(const RT& m00, const RT& m01, const RT& m02,
00085                              const RT& m10, const RT& m11, const RT& m12,
00086                              const RT& m22)
00087               : a(m00), b(m01), c(m02), d(m10), e(m11), f(m12), g(m22)
00088              {}
00089 
00090     virtual  ~Aff_transformation_repH2()
00091              {}
00092 
00093 
00094     virtual  Point_2
00095              transform(const Point_2& p) const
00096              {
00097                return Point_2( a * p.hx() + b * p.hy() + c * p.hw(),
00098                                d * p.hx() + e * p.hy() + f * p.hw(),
00099                                g * p.hw() );
00100              }
00101 
00102     virtual  Vector_2
00103              transform(const Vector_2& v) const
00104              {
00105                return Vector_2( a * v.hx() + b * v.hy(),
00106                                 d * v.hx() + e * v.hy(),
00107                                 g * v.hw() );
00108              }
00109 
00110     virtual  Direction_2
00111              transform(const Direction_2& dir) const
00112              {
00113                if ( g > RT(0) )
00114                    return Direction_2( a * dir.x() + b * dir.y(),
00115                                        d * dir.x() + e * dir.y() );
00116                else
00117                    return - Direction_2(a * dir.x() + b * dir.y(),
00118                                         d * dir.x() + e * dir.y() );
00119              }
00120 
00121     virtual  Aff_transformationH2<R>
00122              inverse() const
00123              {
00124                 RT  ai =   e*g;
00125                 RT  bi = - b*g;
00126                 RT  ci =   b*f - e*c;
00127                 RT  di = - d*g;
00128                 RT  ei =   a*g;
00129                 RT  fi =   d*c - a*f;
00130                 RT  gi =   a*e - b*d;
00131                 return Aff_transformationH2<R>( ai, bi, ci,
00132                                                     di, ei, fi,
00133                                                             gi) ;
00134              }
00135 
00136 
00137     virtual   Aff_transformation_repH2<R>
00138               general_form() const
00139               { return *this; }
00140 
00141     virtual   bool
00142               is_even() const
00143               { return CGAL_NTS sign<RT>( (a*e - b*d)*g ) == POSITIVE; }
00144 
00145     virtual   RT   homogeneous(int i, int j) const;
00146     virtual   FT   cartesian(int i, int j) const;
00147 
00148     RT    a;           //    |  a  b  c  |   | x |   | xn |
00149     RT    b;           //    |  d  e  f  | * | y | = | yn |
00150     RT    c;           //    |  0  0  g  |   | w |   | wn |
00151     RT    d;
00152     RT    e;
00153     RT    f;
00154     RT    g;
00155 
00156   friend Aff_transformationH2<R>
00157          _general_transformation_composition <> (
00158                                    Aff_transformation_repH2<R> l,
00159                                    Aff_transformation_repH2<R> r);
00160 };
00161 
00162 template < class R >
00163 class Identity_repH2 : public Aff_transformation_rep_baseH2<R>
00164 {
00165   public:
00166     typedef typename R::RT         RT;
00167     typedef typename R::FT         FT;
00168     typedef typename R::Point_2      Point_2;
00169     typedef typename R::Vector_2     Vector_2;
00170     typedef typename R::Direction_2  Direction_2;
00171 
00172              Identity_repH2()
00173              {}
00174 
00175     virtual  ~Identity_repH2()
00176              {}
00177 
00178 
00179     virtual  Point_2
00180              transform(const Point_2 & p) const
00181              { return p; }
00182 
00183     virtual  Vector_2
00184              transform(const Vector_2 & v) const
00185              { return v; }
00186 
00187     virtual  Direction_2
00188              transform(const Direction_2 & d) const
00189              { return d; }
00190 
00191     virtual  Aff_transformationH2<R>
00192              inverse() const
00193              { return Aff_transformationH2<R>(IDENTITY); }
00194 
00195     virtual  bool
00196              is_even() const
00197              { return true; }
00198 
00199     virtual  Aff_transformation_repH2<R>
00200              general_form() const
00201              {
00202                const RT RT0(0);
00203                const RT RT1(1);
00204                return Aff_transformation_repH2<R>(  RT1, RT0, RT0,
00205                                                     RT0, RT1, RT0,
00206                                                     RT1 );
00207              }
00208 
00209     virtual  RT
00210              homogeneous(int i, int j) const
00211              { return (i==j) ? RT(1) : RT(0); }
00212     virtual  FT
00213              cartesian(int i, int j) const
00214              { return (i==j) ? FT(1) : FT(0); }
00215 };
00216 
00217 template < class R >
00218 class Translation_repH2 : public Aff_transformation_rep_baseH2<R>
00219 {
00220   public:
00221     typedef typename R::RT RT;
00222     typedef typename R::FT FT;
00223     typedef typename R::Point_2      Point_2;
00224     typedef typename R::Vector_2     Vector_2;
00225     typedef typename R::Direction_2  Direction_2;
00226 
00227              Translation_repH2()
00228              {}
00229 
00230              Translation_repH2(const Vector_2 & tv) : _tv(tv)
00231              {}
00232 
00233     virtual  ~Translation_repH2()
00234              {}
00235 
00236     virtual  Point_2
00237              transform(const Point_2 & p) const
00238              { return (p + _tv); }
00239 
00240     virtual  Vector_2
00241              transform(const Vector_2 & v) const
00242              { return (v); }
00243 
00244     virtual  Direction_2
00245              transform(const Direction_2 & d) const
00246              { return (d); }
00247 
00248     virtual  Aff_transformationH2<R>
00249              inverse() const
00250              { return Aff_transformationH2<R>(TRANSLATION, - _tv); }
00251 
00252     virtual  bool
00253              is_even() const
00254              { return true; }
00255 
00256     virtual  Aff_transformation_repH2<R>
00257              general_form() const
00258              {
00259                return
00260                Aff_transformation_repH2<R>( _tv.hw(), RT(0) ,  _tv.hx(),
00261                                                RT(0), _tv.hw(),  _tv.hy(),
00262                                                                  _tv.hw() );
00263              }
00264 
00265     virtual  RT   homogeneous(int i, int j) const;
00266     virtual  FT   cartesian(int i, int j) const;
00267 
00268   private:
00269     Vector_2 _tv;
00270 };
00271 
00272 template < class R >
00273 class Rotation_repH2 : public Aff_transformation_rep_baseH2<R>
00274 {
00275   public:
00276     typedef typename R::RT RT;
00277     typedef typename R::FT FT;
00278     typedef typename R::Point_2      Point_2;
00279     typedef typename R::Vector_2     Vector_2;
00280     typedef typename R::Direction_2  Direction_2;
00281 
00282              Rotation_repH2()
00283              {
00284              }
00285              Rotation_repH2(const RT& sin, const RT& cos, const RT& den) :
00286                _sin(sin), _cos(cos), _den(den)
00287              {
00288                if ( den < RT(0)   )
00289                {
00290                  _sin = - _sin;
00291                  _cos = - _cos;
00292                  _den = - _den;
00293                };
00294              }
00295              ~Rotation_repH2()
00296              {
00297              }
00298 
00299     virtual  Point_2
00300              transform(const Point_2 & p) const
00301              {
00302                return Point_2( p.hx()*_cos  - p.hy()*_sin,
00303                                p.hx()*_sin  + p.hy()*_cos,
00304                                p.hw()*_den );
00305              }
00306     virtual  Vector_2
00307              transform(const Vector_2 & v) const
00308              {
00309                return Vector_2( v.hx()*_cos  - v.hy()*_sin,
00310                                             v.hx()*_sin  + v.hy()*_cos,
00311                                             v.hw()*_den );
00312              }
00313     virtual  Direction_2
00314              transform(const Direction_2 & d) const
00315              {
00316                return Direction_2( d.x()*_cos  - d.y()*_sin,
00317                                    d.x()*_sin  + d.y()*_cos);
00318              }
00319     virtual  Aff_transformationH2<R>
00320              inverse() const
00321              {
00322                return Aff_transformationH2<R>(ROTATION,
00323                                                        - _sin, _cos, _den);
00324              }
00325     virtual  bool
00326              is_even() const
00327              {
00328                return true;
00329              }
00330     virtual  Aff_transformation_repH2<R>
00331              general_form() const
00332              {
00333                return Aff_transformation_repH2<R>(
00334                            _cos,  - _sin,  RT(0)  ,
00335                            _sin,    _cos,  RT(0)  ,
00336                                            _den );
00337              }
00338 
00339     virtual  RT   homogeneous(int i, int j) const;
00340     virtual  FT   cartesian(int i, int j) const;
00341 
00342   private:
00343     RT  _sin;
00344     RT  _cos;
00345     RT  _den;
00346 };
00347 
00348 template < class R >
00349 class Scaling_repH2 : public Aff_transformation_rep_baseH2<R>
00350 {
00351   public:
00352     typedef typename R::RT RT;
00353     typedef typename R::FT FT;
00354     typedef typename R::Point_2      Point_2;
00355     typedef typename R::Vector_2     Vector_2;
00356     typedef typename R::Direction_2  Direction_2;
00357 
00358              Scaling_repH2()
00359              {}
00360 
00361              Scaling_repH2(const RT& scaling_numerator,
00362                                  const RT& scaling_denominator) :
00363                _sf_num(scaling_numerator), _sf_den(scaling_denominator)
00364              {
00365                if ( scaling_denominator < RT(0)   )
00366                {
00367                  _sf_num = - _sf_num;
00368                  _sf_den = - _sf_den;
00369                };
00370              }
00371 
00372     virtual  ~Scaling_repH2()
00373              {}
00374 
00375     virtual  Point_2
00376              transform(const Point_2 & p) const
00377              {
00378                return Point_2( p.hx() * _sf_num,
00379                                p.hy() * _sf_num,
00380                                p.hw() * _sf_den );
00381              }
00382     virtual  Vector_2
00383              transform(const Vector_2 & v) const
00384              {
00385                return Vector_2( v.hx() * _sf_num,
00386                                 v.hy() * _sf_num,
00387                                 v.hw() * _sf_den );
00388              }
00389     virtual  Direction_2
00390              transform(const Direction_2 & d) const
00391              { return (d); }
00392 
00393     virtual  Aff_transformationH2<R>
00394              inverse() const
00395              { return Aff_transformationH2<R>(SCALING, _sf_den, _sf_num); }
00396 
00397     virtual  bool
00398              is_even() const
00399              { return true; }
00400 
00401     virtual  Aff_transformation_repH2<R>
00402              general_form() const
00403              {
00404                return
00405                Aff_transformation_repH2<R>(_sf_num, RT(0)  , RT(0)  ,
00406                                                RT(0)  , _sf_num, RT(0)  ,
00407                                                                  _sf_den );
00408              }
00409 
00410     virtual  RT   homogeneous(int i, int j) const;
00411     virtual  FT   cartesian(int i, int j) const;
00412 
00413 
00414   private:
00415     RT  _sf_num;
00416     RT  _sf_den;
00417 };
00418 
00419 template < class R >
00420 class Reflection_repH2 : public Aff_transformation_rep_baseH2<R>
00421 {
00422   public:
00423     typedef typename R::RT RT;
00424     typedef typename R::FT FT;
00425     typedef typename R::Point_2      Point_2;
00426     typedef typename R::Vector_2     Vector_2;
00427     typedef typename R::Direction_2  Direction_2;
00428     typedef typename R::Line_2       Line_2;
00429 
00430              Reflection_repH2(const Line_2& l_) : l(l_) {}
00431 
00432     virtual  ~Reflection_repH2()
00433              {}
00434 
00435     virtual  Point_2
00436              transform(const Point_2 & p) const
00437              {
00438                Point_2 pp = l.projection(p);
00439                return p + (pp - p)*RT(2);
00440              }
00441 
00442     virtual  Vector_2
00443              transform(const Vector_2 & v) const
00444              {
00445                Line_2 l0( l.a(), l.b(), RT(0));
00446                Point_2 p = ORIGIN + v;
00447                Point_2 pp = l0.projection(p);
00448                return (p + (pp - p)*RT(2)) - ORIGIN;
00449              }
00450 
00451     virtual  Direction_2
00452              transform(const Direction_2 & d) const
00453              { return transform( Vector_2(d) ).direction(); }
00454 
00455     virtual  Aff_transformationH2<R>
00456              inverse() const
00457              {
00458                return Aff_transformationH2<R>(
00459                    static_cast< Aff_transformation_rep_baseH2<R>* >
00460                    ( const_cast< Reflection_repH2<R>*> (this) )  );
00461              }
00462 
00463     virtual  bool
00464              is_even() const
00465              { return false; }
00466 
00467     virtual  Aff_transformation_repH2<R>
00468              general_form() const
00469              {
00470                const RT mRT2 = - RT(2);
00471                const RT& a = l.a();
00472                const RT& b = l.b();
00473                const RT& c = l.c();
00474                RT de = a*a + b*b;
00475                RT aa = b*b - a*a;
00476                RT bb = a*a - b*b;
00477                RT ab = a*b* mRT2;
00478                RT ac = a*c* mRT2;
00479                RT bc = b*c* mRT2;
00480                return
00481                Aff_transformation_repH2<R>( aa, ab, ac,
00482                                                 ab, bb, bc,
00483                                                         de );
00484              }
00485 
00486     virtual  RT   homogeneous(int i, int j) const;
00487     virtual  FT   cartesian(int i, int j) const;
00488 
00489 
00490   private:
00491     Line_2   l;
00492 };
00493 
00494 
00495 template < class R_ >
00496 class Aff_transformationH2
00497   : public Handle_for_virtual< Aff_transformation_rep_baseH2<R_> >
00498 {
00499   typedef typename R_::FT                        FT;
00500   typedef typename R_::RT                        RT;
00501   typedef typename R_::Point_2      Point_2;
00502   typedef typename R_::Vector_2     Vector_2;
00503   typedef typename R_::Direction_2  Direction_2;
00504   typedef typename R_::Line_2       Line_2;
00505 
00506 public:
00507   typedef R_                                    R;
00508 
00509           Aff_transformationH2();
00510 
00511           // Identity:
00512 
00513           Aff_transformationH2(const Identity_transformation);
00514 
00515           // Translation:
00516 
00517           Aff_transformationH2(const Translation, const Vector_2& v);
00518 
00519           // Scaling:
00520 
00521           Aff_transformationH2(const Scaling, const RT& a,  
00522                                const RT& b = RT(1));
00523 
00524           Aff_transformationH2(const Scaling, const RT& xa, const RT& xb,
00525                                               const RT& ya, const RT& yb);
00526 
00527           // Reflection:
00528           Aff_transformationH2(const Reflection, const Line_2& l);
00529 
00530           // Rational Rotation:
00531 
00532           Aff_transformationH2(const Rotation,
00533                                const RT& sine,
00534                                const RT& cosine,
00535                                const RT& denominator);
00536 
00537           Aff_transformationH2(const Rotation,
00538                                const Direction_2& dir,
00539                                const RT& n,
00540                                const RT& d = RT(1));
00541 
00542           // Orthogonal Transformation:
00543 
00544           Aff_transformationH2(const Vector_2& v,
00545                                const RT& sine,
00546                                const RT& cosine,
00547                                const RT& denominator,
00548                                const RT& scaling_numerator = RT(1),
00549                                const RT& scaling_denominator = RT(1))
00550   {
00551     Aff_transformationH2<R>
00552         scaling(SCALING,scaling_numerator,scaling_denominator);
00553     Aff_transformationH2<R> combination =
00554           Aff_transformationH2<R>(TRANSLATION, scaling.inverse().transform(-v))
00555         * scaling
00556         * Aff_transformationH2<R>(ROTATION, sine, cosine, denominator)
00557         * Aff_transformationH2<R>(TRANSLATION, v ) ;
00558 
00559     *this = combination;
00560   }
00561 
00562           // General affine transformation
00563           //    | a b c |   |x|
00564           //    | d e f | * |y|
00565           //    | 0 0 g |   |w|
00566 
00567           Aff_transformationH2(const RT& a, const RT& b, const RT& c,
00568                                const RT& d, const RT& e, const RT& f,
00569                                                          const RT& g = RT(1));
00570 
00571           Aff_transformationH2(const RT& a, const RT& b,
00572                                const RT& d, const RT& e,
00573                                                          const RT& g = RT(1));
00574 
00575     Point_2     transform(const Point_2& p) const;
00576     Vector_2    transform(const Vector_2& v) const;
00577     Direction_2 transform(const Direction_2& d) const;
00578     Line_2      transform(const Line_2& l) const;
00579 
00580     Aff_transformationH2<R> inverse() const;
00581     bool                    is_even() const;
00582     bool                    is_odd()  const;
00583 
00584                             // Access functions for matrix form
00585     FT                      cartesian(int i, int j) const;
00586     RT                      homogeneous(int i, int j) const;
00587     FT                      m(int i, int j) const
00588                             { return cartesian(i,j); }
00589     RT                      hm(int i, int j) const
00590                             { return homogeneous(i,j); }
00591 
00592     Aff_transformation_repH2<R>
00593                             general_form() const;
00594 
00595 //  friend   Aff_transformationH2<R>
00596 //    operator* <>
00597 //              (const Aff_transformationH2<R>& left_argument,
00598 //               const Aff_transformationH2<R>& right_argument );
00599 
00600     Aff_transformationH2<R>
00601     operator*(const Aff_transformationH2<R>& right_argument ) const;
00602 
00603 };
00604 
00605 template < class R >
00606 Aff_transformationH2<R>::Aff_transformationH2()
00607 { initialize_with(Aff_transformation_repH2<R>()); }
00608 
00609 template < class R >
00610 Aff_transformationH2<R>::
00611 Aff_transformationH2(const Identity_transformation)
00612 { initialize_with(Identity_repH2<R>()); }
00613 
00614 template < class R >
00615 Aff_transformationH2<R>::
00616 Aff_transformationH2(const Translation,
00617                      const typename Aff_transformationH2<R>::Vector_2& v)
00618 { initialize_with(Translation_repH2<R>( v )); }
00619 
00620 template < class R >
00621 Aff_transformationH2<R>::
00622 Aff_transformationH2(const Scaling, const RT& a, const RT& b)
00623 { initialize_with(Scaling_repH2<R>( a, b)); }
00624 
00625 template < class R >
00626 Aff_transformationH2<R>::
00627 Aff_transformationH2( const Scaling, const RT& xa, const RT& xb,
00628                                      const RT& ya, const RT& yb)
00629 {
00630   initialize_with(Aff_transformation_repH2<R>(xa*yb,  RT(0),  RT(0),
00631                                               RT(0),  ya*xb,  RT(0),
00632                                               xb*yb  ));
00633 }
00634 
00635 template < class R >
00636 Aff_transformationH2<R>::
00637 Aff_transformationH2(const Reflection,
00638                      const typename Aff_transformationH2<R>::Line_2& l)
00639 { initialize_with(Reflection_repH2<R>( l)); }
00640 
00641 template < class R >
00642 Aff_transformationH2<R>::
00643 Aff_transformationH2(const Rotation,
00644                      const RT& sine,
00645                      const RT& cosine,
00646                      const RT& denominator)
00647 { initialize_with(Rotation_repH2<R>(sine, cosine, denominator)); }
00648 
00649 template < class R >
00650 Aff_transformationH2<R>::
00651 Aff_transformationH2(const Rotation,
00652                      const typename Aff_transformationH2<R>::Direction_2& dir,
00653                      const RT& n,
00654                      const RT& d)
00655 {
00656  const RT   RTzero = RT(0)  ;
00657  CGAL_kernel_precondition( n > RTzero );
00658  CGAL_kernel_precondition( d > RTzero );
00659  RT   sin;
00660  RT   cos;
00661  RT   den;
00662 
00663  rational_rotation_approximation(dir.x(), dir.y(), sin, cos, den, n, d);
00664  initialize_with(Rotation_repH2<R>( sin, cos, den ));
00665 }
00666 
00667 template < class R >
00668 Aff_transformationH2<R>::
00669 Aff_transformationH2( const RT& a, const RT& b, const RT& c,
00670                       const RT& d, const RT& e, const RT& f,
00671                                                 const RT& g)
00672 {
00673   initialize_with(Aff_transformation_repH2<R>( a,   b,   c,
00674                                                d,   e,   f,
00675                                                g  ));
00676 }
00677 
00678 template < class R >
00679 Aff_transformationH2<R>::
00680 Aff_transformationH2( const RT& a, const RT& b,
00681                       const RT& d, const RT& e,
00682                       const RT& g)
00683 {
00684   initialize_with(Aff_transformation_repH2<R>( a,   b,   RT(0),
00685                                                d,   e,   RT(0),
00686                                                g  ));
00687 }
00688 
00689 template < class R >
00690 typename Aff_transformationH2<R>::Point_2
00691 Aff_transformationH2<R>::
00692 transform(const typename Aff_transformationH2<R>::Point_2& p) const
00693 { return this->Ptr()->transform(p); }
00694 
00695 
00696 template < class R >
00697 typename Aff_transformationH2<R>::Vector_2
00698 Aff_transformationH2<R>::
00699 transform( const typename Aff_transformationH2<R>::Vector_2& v) const
00700 { return this->Ptr()->transform(v); }
00701 
00702 template < class R >
00703 typename Aff_transformationH2<R>::Direction_2
00704 Aff_transformationH2<R>::
00705 transform( const typename Aff_transformationH2<R>::Direction_2& d) const
00706 { return this->Ptr()->transform(d); }
00707 
00708 template < class R >
00709 typename Aff_transformationH2<R>::Line_2
00710 Aff_transformationH2<R>::
00711 transform( const typename Aff_transformationH2<R>::Line_2& l) const
00712 { return Line_2( transform( l.point(0)), transform( l.point(1)) ); }
00713 
00714 template < class R >
00715 Aff_transformationH2<R>
00716 Aff_transformationH2<R>::
00717 inverse() const
00718 { return this->Ptr()->inverse(); }
00719 
00720 template < class R >
00721 bool
00722 Aff_transformationH2<R>::
00723 is_even() const
00724 { return this->Ptr()->is_even(); }
00725 
00726 template < class R >
00727 bool
00728 Aff_transformationH2<R>::
00729 is_odd() const
00730 { return ! is_even(); }
00731 
00732 template < class R >
00733 inline
00734 typename Aff_transformationH2<R>::FT
00735 Aff_transformationH2<R>::
00736 cartesian(int i, int j) const
00737 { return this->Ptr()->cartesian(i,j); }
00738 
00739 template < class R >
00740 inline
00741 typename Aff_transformationH2<R>::RT
00742 Aff_transformationH2<R>::
00743 homogeneous(int i, int j) const
00744 { return this->Ptr()->homogeneous(i,j); }
00745 
00746 template < class R >
00747 Aff_transformation_repH2<R>
00748 Aff_transformationH2<R>::
00749 general_form() const
00750 { return this->Ptr()->general_form(); }
00751 
00752 template <class R>
00753 Aff_transformationH2<R>
00754 //operator*(const Aff_transformationH2<R>& left_argument,
00755 //          const Aff_transformationH2<R>& right_argument )
00756 Aff_transformationH2<R>::
00757 operator*(const Aff_transformationH2<R>& right_argument) const
00758 {
00759   return _general_transformation_composition(
00760                   this->Ptr()->general_form(),
00761                   right_argument.Ptr()->general_form() );
00762 }
00763 
00764 template <class R>
00765 Aff_transformationH2<R>
00766 _general_transformation_composition( Aff_transformation_repH2<R> l,
00767                                      Aff_transformation_repH2<R> r )
00768 {
00769 return Aff_transformationH2<R>(
00770        l.a*r.a + l.b*r.d,   l.a*r.b + l.b*r.e,   l.a*r.c + l.b*r.f + l.c*r.g,
00771        l.d*r.a + l.e*r.d,   l.d*r.b + l.e*r.e,   l.d*r.c + l.e*r.f + l.f*r.g,
00772                                                  l.g*r.g                     );
00773 }
00774 
00775 template < class R >
00776 typename Aff_transformation_repH2<R>::RT
00777 Aff_transformation_repH2<R>::homogeneous(int i, int j) const
00778 {
00779   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00780   switch (i)
00781   {
00782     case 0: switch (j)
00783             {
00784               case 0: return a;
00785               case 1: return b;
00786               case 2: return c;
00787             }
00788     case 1: switch (j)
00789             {
00790               case 0: return d;
00791               case 1: return e;
00792               case 2: return f;
00793             }
00794     case 2: switch (j)
00795             {
00796               case 0: return RT(0);
00797               case 1: return RT(0);
00798               case 2: return g;
00799             }
00800   }
00801   return RT(0);
00802 }
00803 
00804 template < class R >
00805 typename Aff_transformation_repH2<R>::FT
00806 Aff_transformation_repH2<R>::cartesian(int i, int j) const
00807 {
00808   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00809   if ( (i == 2) && (j == 2) )  return FT(1);
00810   return FT(homogeneous(i,j)) / FT(g);
00811 }
00812 
00813 template < class R >
00814 typename Translation_repH2<R>::RT
00815 Translation_repH2<R>::homogeneous(int i, int j) const
00816 {
00817   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00818   switch (i)
00819   {
00820     case 0: switch (j)
00821             {
00822               case 0: return _tv.hw();
00823               case 1: return RT(0);
00824               case 2: return _tv.hx();
00825             }
00826     case 1: switch (j)
00827             {
00828               case 0: return RT(0);
00829               case 1: return _tv.hw();
00830               case 2: return _tv.hy();
00831             }
00832     case 2: switch (j)
00833             {
00834               case 0: return RT(0);
00835               case 1: return RT(0);
00836               case 2: return _tv.hw();
00837             }
00838   }
00839   return RT(0);
00840 }
00841 
00842 template < class R >
00843 typename Translation_repH2<R>::FT
00844 Translation_repH2<R>::cartesian(int i, int j) const
00845 {
00846   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00847   switch (i)
00848   {
00849     case 0: switch (j)
00850             {
00851               case 0: return FT(1);
00852               case 1: return FT(0);
00853               case 2: return _tv.x();
00854             }
00855     case 1: switch (j)
00856             {
00857               case 0: return FT(0);
00858               case 1: return FT(1);
00859               case 2: return _tv.y();
00860             }
00861     case 2: switch (j)
00862             {
00863               case 0: return FT(0);
00864               case 1: return FT(0);
00865               case 2: return FT(1);
00866             }
00867   }
00868   return FT(0);
00869 }
00870 
00871 template < class R >
00872 typename Rotation_repH2<R>::RT
00873 Rotation_repH2<R>::
00874 homogeneous(int i, int j) const
00875 {
00876   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00877   switch (i)
00878   {
00879     case 0: switch (j)
00880             {
00881               case 0: return _cos;
00882               case 1: return - _sin;
00883               case 2: return RT(0);
00884             }
00885     case 1: switch (j)
00886             {
00887               case 0: return _sin;
00888               case 1: return _cos;
00889               case 2: return RT(0);
00890             }
00891     case 2: switch (j)
00892             {
00893               case 0: return RT(0);
00894               case 1: return RT(0);
00895               case 2: return _den;
00896             }
00897   }
00898   return RT(0);
00899 }
00900 
00901 template < class R >
00902 typename Rotation_repH2<R>::FT
00903 Rotation_repH2<R>::
00904 cartesian(int i, int j) const
00905 {
00906   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00907   switch (i)
00908   {
00909     case 0: switch (j)
00910             {
00911               case 0: return FT(_cos) / FT(_den);
00912               case 1: return - FT(_sin) / FT(_den);
00913               case 2: return RT(0);
00914             }
00915     case 1: switch (j)
00916             {
00917               case 0: return FT(_sin) / FT(_den);
00918               case 1: return FT(_cos) / FT(_den);
00919               case 2: return FT(0);
00920             }
00921     case 2: switch (j)
00922             {
00923               case 0: return FT(0);
00924               case 1: return FT(0);
00925               case 2: return FT(1);
00926             }
00927   }
00928   return FT(0);
00929 }
00930 
00931 template < class R >
00932 typename Scaling_repH2<R>::RT
00933 Scaling_repH2<R>::
00934 homogeneous(int i, int j) const
00935 {
00936   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00937   switch (i)
00938   {
00939     case 0: switch (j)
00940             {
00941               case 0: return _sf_num;
00942               case 1: return RT(0);
00943               case 2: return RT(0);
00944             }
00945     case 1: switch (j)
00946             {
00947               case 0: return RT(0);
00948               case 1: return _sf_num;
00949               case 2: return RT(0);
00950             }
00951     case 2: switch (j)
00952             {
00953               case 0: return RT(0);
00954               case 1: return RT(0);
00955               case 2: return _sf_den;
00956             }
00957   }
00958   return RT(0);
00959 }
00960 
00961 template <class R>
00962 typename Scaling_repH2<R>::FT
00963 Scaling_repH2<R>::
00964 cartesian(int i, int j) const
00965 {
00966   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00967   switch (i)
00968   {
00969     case 0: switch (j)
00970             {
00971               case 0: return FT(_sf_num) / FT(_sf_den);
00972               case 1: return FT(0);
00973               case 2: return FT(0);
00974             }
00975     case 1: switch (j)
00976             {
00977               case 0: return FT(0);
00978               case 1: return FT(_sf_num) / FT(_sf_den);
00979               case 2: return FT(0);
00980             }
00981     case 2: switch (j)
00982             {
00983               case 0: return FT(0);
00984               case 1: return FT(0);
00985               case 2: return FT(1);
00986             }
00987   }
00988   return FT(0);
00989 }
00990 
00991 template < class R >
00992 typename Reflection_repH2<R>::RT
00993 Reflection_repH2<R>::
00994 homogeneous(int i, int j) const
00995 {
00996   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
00997   RT mRT2 = -RT(2);
00998   switch (i)
00999   {
01000     case 0: switch (j)
01001             {
01002               case 0: return l.b()*l.b() - l.a()*l.a();
01003               case 1: return l.a()*l.b()*mRT2;
01004               case 2: return l.a()*l.c()*mRT2;
01005             }
01006     case 1: switch (j)
01007             {
01008               case 0: return l.a()*l.b()*mRT2;
01009               case 1: return l.a()*l.a() - l.b()*l.b();
01010               case 2: return l.b()*l.c()*mRT2;
01011             }
01012     case 2: switch (j)
01013             {
01014               case 0: return RT(0);
01015               case 1: return RT(0);
01016               case 2: return l.a()*l.a() + l.b()*l.b();
01017             }
01018   }
01019   return RT(0);
01020 }
01021 
01022 template <class R>
01023 typename Reflection_repH2<R>::FT
01024 Reflection_repH2<R>::
01025 cartesian(int i, int j) const
01026 {
01027   CGAL_kernel_precondition( (i >= 0) && (i <= 2) && (j >= 0) && (j <= 2) );
01028   FT de = FT( l.a()*l.a() + l.b()*l.b() );
01029   switch (i)
01030   {
01031     case 0: switch (j)
01032             {
01033               case 0: return FT( l.b()-l.a() ) / FT( l.a()+l.b());
01034               case 1: return FT( homogeneous(0,1)) / de;
01035               case 2: return FT( homogeneous(0,2)) / de;
01036             }
01037     case 1: switch (j)
01038             {
01039               case 0: return FT( homogeneous(1,0)) / de;
01040               case 1: return FT( l.a()-l.b() ) / FT( l.a()+l.b());
01041               case 2: return FT( homogeneous(1,2)) / de;
01042             }
01043     case 2: switch (j)
01044             {
01045               case 0: return FT(0);
01046               case 1: return FT(0);
01047               case 2: return FT(1);
01048             }
01049   }
01050   return FT(0);
01051 }
01052 
01053 CGAL_END_NAMESPACE
01054 
01055 #endif // CGAL_AFF_TRANSFORMATIONH2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines