BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Homogeneous/Aff_transformationH3.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_transformationH3.h $
00019 // $Id: Aff_transformationH3.h 42811 2008-04-09 13:35:34Z spion $
00020 // 
00021 //
00022 // Author(s)     : Stefan Schirra
00023 
00024 #ifndef CGAL_AFF_TRANSFORMATIONH3_H
00025 #define CGAL_AFF_TRANSFORMATIONH3_H
00026 
00027 #include <CGAL/Handle_for_virtual.h>
00028 #include <CGAL/determinant.h>
00029 
00030 CGAL_BEGIN_NAMESPACE
00031 
00032 // forward declaration
00033 template < class R >
00034 class Aff_transformationH3;
00035 
00036 template < class R >
00037 class Aff_transformation_repH3;
00038 
00039 template < class R >
00040 std::ostream &
00041 operator<< ( std::ostream & out,
00042              const Aff_transformationH3<R>& t);
00043 
00044 template < class R >
00045 Aff_transformationH3<R>
00046 _general_transformation_composition (
00047                            Aff_transformation_repH3<R> l,
00048                            Aff_transformation_repH3<R> r);
00049 
00050 template <class R_ >
00051 class Aff_transformation_rep_baseH3 : public Ref_counted_virtual
00052 // abstract base class of aff transformation representations
00053 {
00054 public:
00055   typedef R_                         R;
00056   typedef typename R::FT             FT;
00057   typedef typename R::RT             RT;
00058   typedef typename R::Point_3        Point_3;
00059   typedef typename R::Vector_3       Vector_3;
00060   typedef typename R::Direction_3    Direction_3;
00061   typedef typename R::Plane_3        Plane_3;
00062   typedef typename R::Aff_transformation_3 Aff_transformation_3;
00063 
00064   virtual  ~Aff_transformation_rep_baseH3(){}
00065 
00066   virtual  Point_3
00067            transform(const Point_3&) const = 0;
00068 
00069   virtual  Vector_3
00070            transform(const Vector_3&) const = 0;
00071 
00072   virtual  Direction_3
00073            transform(const Direction_3&) const = 0;
00074 
00075   virtual  Plane_3
00076            transform(const Plane_3&) const = 0;
00077 
00078   virtual  Aff_transformation_3
00079            inverse() const = 0;
00080 
00081   virtual  Aff_transformation_3
00082            transpose() const = 0;
00083 
00084   virtual  Aff_transformation_repH3<R>
00085            general_form() const = 0;
00086 
00087   virtual  bool
00088            is_even() const = 0;
00089 
00090   virtual  RT
00091            homogeneous(int i, int j) const = 0;
00092 
00093   virtual  FT
00094            cartesian(int i, int j) const = 0;
00095 };
00096 
00097 template < class R_ >
00098 class Aff_transformation_repH3 : public Aff_transformation_rep_baseH3<R_>
00099 {
00100   typedef typename R_::FT           FT;
00101   typedef typename R_::RT           RT;
00102   typedef typename R_::Point_3              Point_3;
00103   typedef typename R_::Vector_3             Vector_3;
00104   typedef typename R_::Direction_3          Direction_3;
00105   typedef typename R_::Plane_3              Plane_3;
00106   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00107 
00108 public:
00109   typedef R_                       R;
00110 
00111   Aff_transformation_repH3() {}
00112 
00113   Aff_transformation_repH3(
00114                  const RT& m00, const RT& m01, const RT& m02, const RT& m03,
00115                  const RT& m10, const RT& m11, const RT& m12, const RT& m13,
00116                  const RT& m20, const RT& m21, const RT& m22, const RT& m23,
00117                                                               const RT& m33);
00118   virtual  ~Aff_transformation_repH3() {}
00119 
00120   virtual  Point_3
00121            transform(const Point_3& p) const;
00122 
00123   virtual  Vector_3
00124            transform(const Vector_3& v) const;
00125 
00126   virtual  Direction_3
00127            transform(const Direction_3& dir) const;
00128 
00129   virtual  Plane_3
00130            transform(const Plane_3& pl) const;
00131 
00132   virtual  Aff_transformation_3
00133            inverse() const;
00134 
00135   virtual  Aff_transformation_repH3<R>
00136            general_form() const;
00137 
00138   virtual  Aff_transformation_3
00139            transpose() const;
00140 
00141   virtual  bool
00142            is_even() const;
00143 
00144   virtual  RT
00145            homogeneous(int i, int j) const ;
00146 
00147   virtual  FT
00148            cartesian(int i, int j) const ;
00149 
00150   friend class Aff_transformationH3<R>;
00151 
00152   friend
00153   Aff_transformationH3<R>
00154   _general_transformation_composition <> (
00155                            Aff_transformation_repH3<R> l,
00156                            Aff_transformation_repH3<R> r);
00157 
00158   friend
00159   std::ostream &
00160   operator<< <> (std::ostream & out, const Aff_transformationH3<R>& t);
00161 
00162 private:
00163     RT   t00, t01, t02, t03;
00164     RT   t10, t11, t12, t13;
00165     RT   t20, t21, t22, t23;
00166     RT                  t33;
00167 };
00168 
00169 template < class R_ >
00170 class Identity_repH3 : public Aff_transformation_rep_baseH3<R_>
00171 {
00172   typedef typename R_::RT    RT;
00173   typedef typename R_::FT    FT;
00174   typedef typename R_::Point_3              Point_3;
00175   typedef typename R_::Vector_3             Vector_3;
00176   typedef typename R_::Direction_3          Direction_3;
00177   typedef typename R_::Plane_3              Plane_3;
00178   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00179 
00180 public:
00181   typedef R_                R;
00182 
00183            Identity_repH3()
00184            {}
00185 
00186   virtual  ~Identity_repH3()
00187            {}
00188 
00189   virtual  Point_3
00190            transform(const Point_3& p) const
00191            { return p; }
00192 
00193   virtual  Vector_3
00194            transform(const Vector_3& v) const
00195            { return v; }
00196 
00197   virtual  Direction_3
00198            transform(const Direction_3& dir) const
00199            { return dir; }
00200 
00201   virtual  Plane_3
00202            transform(const Plane_3& pl) const
00203            { return pl; }
00204 
00205   virtual  Aff_transformation_3
00206            inverse() const
00207            { return Aff_transformation_3( IDENTITY); }
00208 
00209   virtual  Aff_transformation_repH3<R>
00210            general_form() const;
00211 
00212   virtual  Aff_transformation_3
00213            transpose() const
00214            { return Aff_transformation_3( IDENTITY); }
00215 
00216   virtual  bool
00217            is_even() const
00218            { return true; }
00219 
00220   virtual  RT
00221            homogeneous(int i, int j) const
00222            { return (i==j) ? RT(1) : RT(0); }
00223 
00224   virtual  FT
00225            cartesian(int i, int j) const
00226            { return (i==j) ? FT(1) : FT(0); }
00227 };
00228 
00229 template < class R_ >
00230 class Translation_repH3 : public Aff_transformation_rep_baseH3<R_>
00231 {
00232   typedef typename R_::FT       FT;
00233   typedef typename R_::RT       RT;
00234   typedef typename R_::Point_3              Point_3;
00235   typedef typename R_::Vector_3             Vector_3;
00236   typedef typename R_::Direction_3          Direction_3;
00237   typedef typename R_::Plane_3              Plane_3;
00238   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00239 
00240 public:
00241   typedef R_                    R;
00242 
00243            Translation_repH3( const Vector_3& v);
00244 
00245   virtual  ~Translation_repH3() {}
00246 
00247 
00248   virtual  Point_3
00249            transform(const Point_3& p) const;
00250 
00251   virtual  Vector_3
00252            transform(const Vector_3& v) const;
00253 
00254   virtual  Direction_3
00255            transform(const Direction_3& dir) const;
00256 
00257   virtual  Plane_3
00258            transform(const Plane_3& pl) const;
00259 
00260   virtual  Aff_transformation_3
00261            inverse() const;
00262 
00263   virtual  Aff_transformation_repH3<R>
00264            general_form() const;
00265 
00266   virtual  Aff_transformation_3
00267            transpose() const;
00268 
00269   virtual  bool
00270            is_even() const;
00271 
00272   virtual  RT
00273            homogeneous(int i, int j) const ;
00274 
00275   virtual  FT
00276            cartesian(int i, int j) const ;
00277 
00278 friend class Aff_transformationH3<R>;
00279 
00280 private:
00281   Vector_3  tv;
00282 };
00283 
00284 template < class R_ >
00285 class Aff_transformationH3
00286   : public Handle_for_virtual< Aff_transformation_rep_baseH3<R_> >
00287 {
00288   typedef typename R_::RT                   RT;
00289   typedef typename R_::FT                   FT;
00290   typedef typename R_::Point_3              Point_3;
00291   typedef typename R_::Vector_3             Vector_3;
00292   typedef typename R_::Direction_3          Direction_3;
00293   typedef typename R_::Plane_3              Plane_3;
00294   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
00295 
00296 public:
00297   typedef R_                R;
00298 
00299   Aff_transformationH3();
00300 
00301   // Identity
00302   Aff_transformationH3(const Identity_transformation&);
00303 
00304   // Translation
00305   Aff_transformationH3(const Translation& , const Vector_3& v);
00306 
00307   //  Scaling
00308   Aff_transformationH3(const Scaling&, const RT& num, const RT& den);
00309 
00310   //  General form
00311   Aff_transformationH3(
00312                   const RT& m00, const RT& m01, const RT& m02, const RT& m03,
00313                   const RT& m10, const RT& m11, const RT& m12, const RT& m13,
00314                   const RT& m20, const RT& m21, const RT& m22, const RT& m23,
00315                                                                const RT& m33);
00316   Aff_transformationH3(
00317                   const RT& m00, const RT& m01, const RT& m02,
00318                   const RT& m10, const RT& m11, const RT& m12,
00319                   const RT& m20, const RT& m21, const RT& m22,
00320                                                                const RT& m33);
00321 
00322   Point_3
00323   transform(const Point_3& p) const;
00324 
00325   Vector_3
00326   transform(const Vector_3& v) const;
00327 
00328   Direction_3
00329   transform(const Direction_3& d) const;
00330 
00331   Plane_3
00332   transform(const Plane_3& pl) const;
00333 
00334   Aff_transformation_3
00335   inverse()   const;
00336 
00337   Aff_transformationH3<R>
00338   transpose() const;
00339 
00340   bool
00341   is_even()   const;
00342 
00343   bool
00344   is_odd()    const;
00345 
00346   FT
00347   cartesian(int i, int j) const
00348   { return this->Ptr()->cartesian(i,j); }
00349 
00350   RT
00351   homogeneous(int i, int j) const
00352   { return this->Ptr()->homogeneous(i,j); }
00353 
00354   FT
00355   m(int i, int j) const
00356   { return this->Ptr()->cartesian(i,j); }
00357 
00358   RT
00359   hm(int i, int j) const
00360   { return this->Ptr()->homogeneous(i,j); }
00361 };
00362 
00363 template < class R >
00364 CGAL_KERNEL_INLINE
00365 Aff_transformation_repH3<R>::Aff_transformation_repH3(
00366                    const RT& m00, const RT& m01, const RT& m02, const RT& m03,
00367                    const RT& m10, const RT& m11, const RT& m12, const RT& m13,
00368                    const RT& m20, const RT& m21, const RT& m22, const RT& m23,
00369                                                                 const RT& m33)
00370   :  t00(m00), t01(m01), t02(m02), t03(m03),
00371      t10(m10), t11(m11), t12(m12), t13(m13),
00372      t20(m20), t21(m21), t22(m22), t23(m23),
00373                                    t33(m33)
00374 {}
00375 
00376 template < class R >
00377 CGAL_KERNEL_INLINE
00378 typename Aff_transformation_repH3<R>::Point_3
00379 Aff_transformation_repH3<R>::
00380 transform(const typename Aff_transformation_repH3<R>::Point_3& p) const
00381 {
00382   return Point_3(t00 * p.hx() + t01 * p.hy() + t02 * p.hz() + t03 * p.hw(),
00383                  t10 * p.hx() + t11 * p.hy() + t12 * p.hz() + t13 * p.hw(),
00384                  t20 * p.hx() + t21 * p.hy() + t22 * p.hz() + t23 * p.hw(),
00385                  t33 * p.hw());
00386 }
00387 
00388 template < class R >
00389 CGAL_KERNEL_INLINE
00390 typename Aff_transformation_repH3<R>::Vector_3
00391 Aff_transformation_repH3<R>::
00392 transform(const typename Aff_transformation_repH3<R>::Vector_3& v) const
00393 {
00394   return Vector_3(t00 * v.hx() + t01 * v.hy() + t02 * v.hz(),
00395                   t10 * v.hx() + t11 * v.hy() + t12 * v.hz(),
00396                   t20 * v.hx() + t21 * v.hy() + t22 * v.hz(),
00397                   t33 * v.hw() );
00398 }
00399 
00400 template < class R >
00401 CGAL_KERNEL_INLINE
00402 typename Aff_transformation_repH3<R>::Direction_3
00403 Aff_transformation_repH3<R>::
00404 transform(const typename Aff_transformation_repH3<R>::Direction_3& d) const
00405 {
00406     if (t33 > RT(0))
00407         return Direction_3(t00 * d.hx() + t01 * d.hy() + t02 * d.hz(),
00408                            t10 * d.hx() + t11 * d.hy() + t12 * d.hz(),
00409                            t20 * d.hx() + t21 * d.hy() + t22 * d.hz());
00410     else
00411         return - Direction_3(t00 * d.hx() + t01 * d.hy() + t02 * d.hz(),
00412                              t10 * d.hx() + t11 * d.hy() + t12 * d.hz(),
00413                              t20 * d.hx() + t21 * d.hy() + t22 * d.hz());
00414 }
00415 
00416 template < class R >
00417 CGAL_KERNEL_INLINE
00418 typename Aff_transformation_repH3<R>::Plane_3
00419 Aff_transformation_repH3<R>::
00420 transform(const typename Aff_transformation_repH3<R>::Plane_3& pl) const
00421 {
00422   if ( is_even() )
00423   {
00424       return Plane_3(
00425                transform(pl.point() ),
00426                transpose().inverse().transform(pl.orthogonal_direction() ));
00427   }
00428   else
00429   {
00430      return Plane_3(
00431                transform(pl.point() ),
00432                -(transpose().inverse().transform(pl.orthogonal_direction() )));
00433   }
00434 }
00435 
00436 template < class R >
00437 CGAL_KERNEL_INLINE
00438 typename Aff_transformation_repH3<R>::Aff_transformation_3
00439 Aff_transformation_repH3<R>::inverse() const
00440 {
00441   typedef typename R::RT RT;
00442   const RT  RT0(0);
00443   return Aff_transformation_3(
00444                            determinant( t11, t12, t13,
00445                                                    t21, t22, t23,     // i 00
00446                                                    RT0, RT0, t33 ),
00447 
00448                         -  determinant( t01, t02, t03,
00449                                                    t21, t22, t23,     // i 01
00450                                                    RT0, RT0, t33 ),
00451 
00452                            determinant( t01, t02, t03,
00453                                                    t11, t12, t13,     // i 02
00454                                                    RT0, RT0, t33 ),
00455 
00456                         -  determinant( t01, t02, t03,
00457                                                    t11, t12, t13,     // i 03
00458                                                    t21, t22, t23 ),
00459 
00460 
00461                         -  determinant( t10, t12, t13,
00462                                                    t20, t22, t23,     // i 10
00463                                                    RT0, RT0, t33 ),
00464 
00465                            determinant( t00, t02, t03,
00466                                                    t20, t22, t23,     // i 11
00467                                                    RT0, RT0, t33 ),
00468 
00469                         -  determinant( t00, t02, t03,
00470                                                    t10, t12, t13,     // i 12
00471                                                    RT0, RT0, t33 ),
00472 
00473                            determinant( t00, t02, t03,
00474                                                    t10, t12, t13,     // i 13
00475                                                    t20, t22, t23 ),
00476 
00477 
00478                            determinant( t10, t11, t13,
00479                                                    t20, t21, t23,     // i 20
00480                                                    RT0, RT0, t33 ),
00481 
00482                         -  determinant( t00, t01, t03,
00483                                                    t20, t21, t23,     // i 21
00484                                                    RT0, RT0, t33 ),
00485 
00486                            determinant( t00, t01, t03,
00487                                                    t10, t11, t13,     // i 22
00488                                                    RT0, RT0, t33 ),
00489 
00490                         -  determinant( t00, t01, t03,
00491                                                    t10, t11, t13,     // i 23
00492                                                    t20, t21, t23 ),
00493 
00494 
00495                            determinant( t00, t01, t02,
00496                                                    t10, t11, t12,     // i 33
00497                                                    t20, t21, t22 )
00498                                                        ) ;
00499 }
00500 
00501 template < class R >
00502 inline
00503 Aff_transformation_repH3<R>
00504 Aff_transformation_repH3<R>::general_form() const
00505 { return *this; }
00506 
00507 template < class R >
00508 CGAL_KERNEL_INLINE
00509 typename Aff_transformation_repH3<R>::Aff_transformation_3
00510 Aff_transformation_repH3<R>::transpose() const
00511 {
00512   typedef typename R::RT RT;
00513   const RT  RT0(0);
00514   return Aff_transformation_3( t00,    t10,    t20,    RT0,
00515                                t01,    t11,    t21,    RT0,
00516                                t02,    t12,    t22,    RT0,
00517                                                               t33);
00518 }
00519 
00520 template < class R >
00521 CGAL_KERNEL_INLINE
00522 bool
00523 Aff_transformation_repH3<R>::is_even() const
00524 {
00525   return (CGAL_NTS sign<RT>( t33 *
00526                             determinant(t00, t01, t02,
00527                                               t10, t11, t12,
00528                                               t20, t21, t22 ) ) == POSITIVE );
00529 }
00530 
00531 template < class R >
00532 CGAL_KERNEL_LARGE_INLINE
00533 typename Aff_transformation_repH3<R>::RT
00534 Aff_transformation_repH3<R>::
00535 homogeneous(int i, int j) const
00536 {
00537   typedef typename R::RT RT;
00538   CGAL_kernel_precondition( (i >= 0) && (i <= 3) && (j >= 0) && (j <= 3) );
00539   const RT  RT0(0);
00540   switch (i)
00541   {
00542     case 0: switch (j)
00543             {
00544               case 0: return t00;
00545               case 1: return t01;
00546               case 2: return t02;
00547               case 3: return t03;
00548             }
00549     case 1: switch (j)
00550             {
00551               case 0: return t10;
00552               case 1: return t11;
00553               case 2: return t12;
00554               case 3: return t13;
00555             }
00556     case 2: switch (j)
00557             {
00558               case 0: return t20;
00559               case 1: return t21;
00560               case 2: return t22;
00561               case 3: return t23;
00562             }
00563     case 3: switch (j)
00564             {
00565               case 0: return RT0;
00566               case 1: return RT0;
00567               case 2: return RT0;
00568               case 3: return t33;
00569             }
00570   }
00571   return RT0;
00572 }
00573 
00574 template < class R >
00575 inline
00576 typename Aff_transformation_repH3<R>::FT
00577 Aff_transformation_repH3<R>::
00578 cartesian(int i, int j) const
00579 {
00580   typedef typename R::FT FT;
00581   return  FT(homogeneous(i,j)) / FT(t33);
00582 }
00583 
00584 template <class R>
00585 Aff_transformation_repH3<R>
00586 Identity_repH3<R>::general_form() const
00587 {
00588   typedef typename R::RT RT;
00589   const RT  RT0(0);
00590   const RT  RT1(1);
00591   return Aff_transformation_repH3<R>(RT1, RT0, RT0, RT0,
00592                                          RT0, RT1, RT0, RT0,
00593                                          RT0, RT0, RT1, RT0,
00594                                                         RT1 );
00595 }
00596 
00597 template < class R >
00598 inline
00599 Translation_repH3<R>::
00600 Translation_repH3( const typename Translation_repH3<R>::Vector_3& v)
00601  : tv(v)
00602 {}
00603 
00604 template < class R >
00605 CGAL_KERNEL_INLINE
00606 typename Translation_repH3<R>::Point_3
00607 Translation_repH3<R>::
00608 transform(const typename Translation_repH3<R>::Point_3& p) const
00609 {
00610   return Point_3( tv.hw() * p.hx() + tv.hx() * p.hw(),
00611                   tv.hw() * p.hy() + tv.hy() * p.hw(),
00612                   tv.hw() * p.hz() + tv.hz() * p.hw(),
00613                   tv.hw() * p.hw() );
00614 }
00615 
00616 template < class R >
00617 inline
00618 typename Translation_repH3<R>::Vector_3
00619 Translation_repH3<R>::
00620 transform(const typename Translation_repH3<R>::Vector_3& v) const
00621 { return v; }
00622 
00623 template < class R >
00624 inline
00625 typename Translation_repH3<R>::Direction_3
00626 Translation_repH3<R>::
00627 transform(const typename Translation_repH3<R>::Direction_3& dir) const
00628 { return dir; }
00629 
00630 template < class R >
00631 inline
00632 typename Translation_repH3<R>::Plane_3
00633 Translation_repH3<R>::
00634 transform(const typename Translation_repH3<R>::Plane_3& pl) const
00635 {
00636   return Plane_3( transform( pl.point() ), pl.orthogonal_vector() );
00637 }
00638 
00639 template < class R >
00640 inline
00641 typename Translation_repH3<R>::Aff_transformation_3
00642 Translation_repH3<R>::inverse() const
00643 { return Aff_transformation_3(TRANSLATION, - tv ); }
00644 
00645 template < class R >
00646 CGAL_KERNEL_INLINE
00647 Aff_transformation_repH3<R>
00648 Translation_repH3<R>::general_form() const
00649 {
00650   const RT  RT0(0);
00651   return Aff_transformation_repH3<R>(tv.hw(), RT0,  RT0,  tv.hx(),
00652                                          RT0,  tv.hw(), RT0,  tv.hy(),
00653                                          RT0,  RT0,  tv.hw(), tv.hz(),
00654                                                               tv.hw() );
00655 }
00656 
00657 template < class R >
00658 CGAL_KERNEL_INLINE
00659 typename Translation_repH3<R>::Aff_transformation_3
00660 Translation_repH3<R>::transpose() const
00661 {
00662   typedef typename R::RT RT;
00663   const RT  RT0(0);
00664   const RT  RT1(1);
00665   return Aff_transformation_3( RT1,  RT0,  RT0,  RT0,
00666                                RT0,  RT1,  RT0,  RT0,
00667                                RT0,  RT0,  RT1,  RT0,
00668                                RT1 );
00669 }
00670 
00671 template < class R >
00672 inline
00673 bool
00674 Translation_repH3<R>::is_even() const
00675 { return true; }
00676 
00677 template < class R >
00678 CGAL_KERNEL_LARGE_INLINE
00679 typename Translation_repH3<R>::RT
00680 Translation_repH3<R>::homogeneous(int i, int j) const
00681 {
00682   CGAL_kernel_precondition( (i >= 0) && (i <= 3) && (j >= 0) && (j <= 3) );
00683   const RT  RT0(0);
00684   switch (i)
00685   {
00686     case 0: switch (j)
00687             {
00688               case 0: return tv.hw();
00689               case 1: return RT0;
00690               case 2: return RT0;
00691               case 3: return tv.hx();
00692             }
00693     case 1: switch (j)
00694             {
00695               case 0: return RT0;
00696               case 1: return tv.hw();
00697               case 2: return RT0;
00698               case 3: return tv.hy();
00699             }
00700     case 2: switch (j)
00701             {
00702               case 0: return RT0;
00703               case 1: return RT0;
00704               case 2: return tv.hw();
00705               case 3: return tv.hz();
00706             }
00707     case 3: switch (j)
00708             {
00709               case 0: return RT0;
00710               case 1: return RT0;
00711               case 2: return RT0;
00712               case 3: return tv.hw();
00713             }
00714   }
00715   return RT0;
00716 }
00717 
00718 template < class R >
00719 inline
00720 typename Translation_repH3<R>::FT
00721 Translation_repH3<R>::
00722 cartesian(int i, int j) const
00723 {
00724   return FT(homogeneous(i,j)) / FT(tv.hw());
00725 }
00726 
00727 
00728 template < class R >
00729 CGAL_KERNEL_INLINE
00730 Aff_transformationH3<R>
00731 _general_transformation_composition(
00732     Aff_transformation_repH3<R> l,
00733     Aff_transformation_repH3<R> r )
00734 {
00735   return Aff_transformationH3<R>(
00736             l.t00*r.t00 + l.t01*r.t10 + l.t02*r.t20,
00737             l.t00*r.t01 + l.t01*r.t11 + l.t02*r.t21,
00738             l.t00*r.t02 + l.t01*r.t12 + l.t02*r.t22,
00739             l.t00*r.t03 + l.t01*r.t13 + l.t02*r.t23 + l.t03*r.t33,
00740 
00741             l.t10*r.t00 + l.t11*r.t10 + l.t12*r.t20,
00742             l.t10*r.t01 + l.t11*r.t11 + l.t12*r.t21,
00743             l.t10*r.t02 + l.t11*r.t12 + l.t12*r.t22,
00744             l.t10*r.t03 + l.t11*r.t13 + l.t12*r.t23 + l.t13*r.t33,
00745 
00746             l.t20*r.t00 + l.t21*r.t10 + l.t22*r.t20,
00747             l.t20*r.t01 + l.t21*r.t11 + l.t22*r.t21,
00748             l.t20*r.t02 + l.t21*r.t12 + l.t22*r.t22,
00749             l.t20*r.t03 + l.t21*r.t13 + l.t22*r.t23 + l.t23*r.t33,
00750 
00751             l.t33*r.t33 );
00752 }
00753 
00754 template < class R >
00755 CGAL_KERNEL_INLINE
00756 Aff_transformationH3<R>::Aff_transformationH3()
00757 { initialize_with(Aff_transformation_repH3<R>()); }
00758 
00759 template < class R >
00760 CGAL_KERNEL_INLINE
00761 Aff_transformationH3<R>::
00762 Aff_transformationH3(const Identity_transformation&)
00763 { initialize_with(Identity_repH3<R>()); }
00764 
00765 template < class R >
00766 CGAL_KERNEL_INLINE
00767 Aff_transformationH3<R>::
00768 Aff_transformationH3(const Translation&,
00769                      const typename Aff_transformationH3<R>::Vector_3& v)
00770 { initialize_with(Translation_repH3<R>( v )); }
00771 
00772 template < class R >
00773 CGAL_KERNEL_INLINE
00774 Aff_transformationH3<R>::
00775 Aff_transformationH3(const Scaling&, const RT& num, const RT& den)
00776 {
00777   const RT RT0(0);
00778   initialize_with(Aff_transformation_repH3<R>(num, RT0, RT0, RT0,
00779                                             RT0, num, RT0, RT0,
00780                                             RT0, RT0, num, RT0,
00781                                                            den ));
00782 }
00783 
00784 template < class R >
00785 CGAL_KERNEL_INLINE
00786 Aff_transformationH3<R>::
00787 Aff_transformationH3(
00788                   const RT& m00, const RT& m01, const RT& m02, const RT& m03,
00789                   const RT& m10, const RT& m11, const RT& m12, const RT& m13,
00790                   const RT& m20, const RT& m21, const RT& m22, const RT& m23,
00791                                                                const RT& m33)
00792 {
00793   initialize_with(Aff_transformation_repH3<R>(m00, m01, m02, m03,
00794                                             m10, m11, m12, m13,
00795                                             m20, m21, m22, m23,
00796                                                            m33 ));
00797 }
00798 
00799 template < class R >
00800 CGAL_KERNEL_INLINE
00801 Aff_transformationH3<R>::
00802 Aff_transformationH3(
00803                   const RT& m00, const RT& m01, const RT& m02,
00804                   const RT& m10, const RT& m11, const RT& m12,
00805                   const RT& m20, const RT& m21, const RT& m22,
00806                                                                const RT& m33)
00807 {
00808   const RT RT0 = RT(0);
00809   initialize_with(Aff_transformation_repH3<R>(m00, m01, m02, RT0,
00810                                             m10, m11, m12, RT0,
00811                                             m20, m21, m22, RT0,
00812                                                            m33 ));
00813 }
00814 
00815 template < class R >
00816 inline
00817 typename Aff_transformationH3<R>::Point_3
00818 Aff_transformationH3<R>::
00819 transform(const typename Aff_transformationH3<R>::Point_3& p) const
00820 { return this->Ptr()->transform(p); }
00821 
00822 template < class R >
00823 inline
00824 typename Aff_transformationH3<R>::Vector_3
00825 Aff_transformationH3<R>::
00826 transform(const typename Aff_transformationH3<R>::Vector_3& v) const
00827 { return this->Ptr()->transform(v); }
00828 
00829 template < class R >
00830 inline
00831 typename Aff_transformationH3<R>::Direction_3
00832 Aff_transformationH3<R>::
00833 transform(const typename Aff_transformationH3<R>::Direction_3& d) const
00834 { return this->Ptr()->transform(d); }
00835 
00836 template < class R >
00837 inline
00838 typename Aff_transformationH3<R>::Plane_3
00839 Aff_transformationH3<R>::
00840 transform(const typename Aff_transformationH3<R>::Plane_3& pl) const
00841 { return this->Ptr()->transform(pl); }
00842 
00843 template < class R >
00844 inline
00845 typename Aff_transformationH3<R>::Aff_transformation_3
00846 Aff_transformationH3<R>::inverse() const
00847 { return this->Ptr()->inverse(); }
00848 
00849 template < class R >
00850 inline
00851 Aff_transformationH3<R>
00852 Aff_transformationH3<R>::transpose() const
00853 { return this->Ptr()->transpose(); }
00854 
00855 template < class R >
00856 inline
00857 bool
00858 Aff_transformationH3<R>::is_even() const
00859 { return this->Ptr()->is_even(); }
00860 
00861 template < class R >
00862 inline
00863 bool
00864 Aff_transformationH3<R>::is_odd() const
00865 { return ( ! (this->Ptr()->is_even() )); }
00866 
00867 template < class R >
00868 CGAL_KERNEL_INLINE
00869 Aff_transformationH3<R>
00870 operator*(const Aff_transformationH3<R>& left_argument,
00871           const Aff_transformationH3<R>& right_argument )
00872 {
00873  return _general_transformation_composition(
00874               left_argument.Ptr() ->general_form(),
00875               right_argument.Ptr()->general_form() );
00876 }
00877 
00878 template < class R >
00879 std::ostream &
00880 operator<< ( std::ostream & out,
00881              const Aff_transformationH3<R>& t)
00882 {
00883  typename R::RT RT0(0);
00884  Aff_transformation_repH3<R> r = t.Ptr()->general_form();
00885  return  out
00886  << "| "<< r.t00 <<' '<< r.t01 <<' '<< r.t02 <<' '<< r.t03 << " |\n"
00887  << "| "<< r.t10 <<' '<< r.t11 <<' '<< r.t12 <<' '<< r.t13 << " |\n"
00888  << "| "<< r.t20 <<' '<< r.t21 <<' '<< r.t22 <<' '<< r.t23 << " |\n"
00889  << "| "<< RT0   <<' '<< RT0   <<' '<< RT0   <<' '<< r.t33 << " |\n";
00890 }
00891 
00892 CGAL_END_NAMESPACE
00893 
00894 #endif // CGAL_AFF_TRANSFORMATIONH3_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines