⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aff_transformationh3.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) 1999  Utrecht University (The Netherlands),// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),// and Tel-Aviv University (Israel).  All rights reserved.//// This file is part of CGAL (www.cgal.org); you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public License as// published by the Free Software Foundation; version 2.1 of the License.// See the file LICENSE.LGPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h $// $Id: Aff_transformationH3.h 29102 2006-03-06 23:51:27Z spion $// //// Author(s)     : Stefan Schirra#ifndef CGAL_AFF_TRANSFORMATIONH3_H#define CGAL_AFF_TRANSFORMATIONH3_H#include <CGAL/Handle_for_virtual.h>#include <CGAL/determinant.h>CGAL_BEGIN_NAMESPACE// forward declarationtemplate < class R >class Aff_transformationH3;template < class R >class Aff_transformation_repH3;template < class R >std::ostream &operator<< ( std::ostream & out,             const Aff_transformationH3<R>& t);template < class R >Aff_transformationH3<R>_general_transformation_composition (                           Aff_transformation_repH3<R> l,                           Aff_transformation_repH3<R> r);template <class R_ >class Aff_transformation_rep_baseH3 : public Ref_counted_virtual// abstract base class of aff transformation representations{public:  typedef R_                         R;  typedef typename R::FT             FT;  typedef typename R::RT             RT;  typedef typename R::Point_3        Point_3;  typedef typename R::Vector_3       Vector_3;  typedef typename R::Direction_3    Direction_3;  typedef typename R::Plane_3        Plane_3;  typedef typename R::Aff_transformation_3 Aff_transformation_3;  virtual  ~Aff_transformation_rep_baseH3(){}  virtual  Point_3           transform(const Point_3&) const = 0;  virtual  Vector_3           transform(const Vector_3&) const = 0;  virtual  Direction_3           transform(const Direction_3&) const = 0;  virtual  Plane_3           transform(const Plane_3&) const = 0;  virtual  Aff_transformation_3           inverse() const = 0;  virtual  Aff_transformation_3           transpose() const = 0;  virtual  Aff_transformation_repH3<R>           general_form() const = 0;  virtual  bool           is_even() const = 0;  virtual  RT           homogeneous(int i, int j) const = 0;  virtual  FT           cartesian(int i, int j) const = 0;};template < class R_ >class Aff_transformation_repH3 : public Aff_transformation_rep_baseH3<R_>{  typedef typename R_::FT           FT;  typedef typename R_::RT           RT;  typedef typename R_::Point_3              Point_3;  typedef typename R_::Vector_3             Vector_3;  typedef typename R_::Direction_3          Direction_3;  typedef typename R_::Plane_3              Plane_3;  typedef typename R_::Aff_transformation_3 Aff_transformation_3;public:  typedef R_                       R;  Aff_transformation_repH3() {}  Aff_transformation_repH3(                 const RT& m00, const RT& m01, const RT& m02, const RT& m03,                 const RT& m10, const RT& m11, const RT& m12, const RT& m13,                 const RT& m20, const RT& m21, const RT& m22, const RT& m23,                                                              const RT& m33);  virtual  ~Aff_transformation_repH3() {}  virtual  Point_3           transform(const Point_3& p) const;  virtual  Vector_3           transform(const Vector_3& v) const;  virtual  Direction_3           transform(const Direction_3& dir) const;  virtual  Plane_3           transform(const Plane_3& pl) const;  virtual  Aff_transformation_3           inverse() const;  virtual  Aff_transformation_repH3<R>           general_form() const;  virtual  Aff_transformation_3           transpose() const;  virtual  bool           is_even() const;  virtual  RT           homogeneous(int i, int j) const ;  virtual  FT           cartesian(int i, int j) const ;  friend class Aff_transformationH3<R>;  friend  Aff_transformationH3<R>  _general_transformation_composition <> (                           Aff_transformation_repH3<R> l,                           Aff_transformation_repH3<R> r);  friend  std::ostream &  operator<< <> (std::ostream & out, const Aff_transformationH3<R>& t);private:    RT   t00, t01, t02, t03;    RT   t10, t11, t12, t13;    RT   t20, t21, t22, t23;    RT                  t33;};template < class R_ >class Identity_repH3 : public Aff_transformation_rep_baseH3<R_>{  typedef typename R_::RT    RT;  typedef typename R_::FT    FT;  typedef typename R_::Point_3              Point_3;  typedef typename R_::Vector_3             Vector_3;  typedef typename R_::Direction_3          Direction_3;  typedef typename R_::Plane_3              Plane_3;  typedef typename R_::Aff_transformation_3 Aff_transformation_3;public:  typedef R_                R;           Identity_repH3()           {}  virtual  ~Identity_repH3()           {}  virtual  Point_3           transform(const Point_3& p) const           { return p; }  virtual  Vector_3           transform(const Vector_3& v) const           { return v; }  virtual  Direction_3           transform(const Direction_3& dir) const           { return dir; }  virtual  Plane_3           transform(const Plane_3& pl) const           { return pl; }  virtual  Aff_transformation_3           inverse() const           { return Aff_transformation_3( IDENTITY); }  virtual  Aff_transformation_repH3<R>           general_form() const;  virtual  Aff_transformation_3           transpose() const           { return Aff_transformation_3( IDENTITY); }  virtual  bool           is_even() const           { return true; }  virtual  RT           homogeneous(int i, int j) const           { return (i==j) ? RT(1) : RT(0); }  virtual  FT           cartesian(int i, int j) const           { return (i==j) ? FT(1) : FT(0); }};template < class R_ >class Translation_repH3 : public Aff_transformation_rep_baseH3<R_>{  typedef typename R_::FT       FT;  typedef typename R_::RT       RT;  typedef typename R_::Point_3              Point_3;  typedef typename R_::Vector_3             Vector_3;  typedef typename R_::Direction_3          Direction_3;  typedef typename R_::Plane_3              Plane_3;  typedef typename R_::Aff_transformation_3 Aff_transformation_3;public:  typedef R_                    R;           Translation_repH3( const Vector_3& v);  virtual  ~Translation_repH3() {}  virtual  Point_3           transform(const Point_3& p) const;  virtual  Vector_3           transform(const Vector_3& v) const;  virtual  Direction_3           transform(const Direction_3& dir) const;  virtual  Plane_3           transform(const Plane_3& pl) const;  virtual  Aff_transformation_3           inverse() const;  virtual  Aff_transformation_repH3<R>           general_form() const;  virtual  Aff_transformation_3           transpose() const;  virtual  bool           is_even() const;  virtual  RT           homogeneous(int i, int j) const ;  virtual  FT           cartesian(int i, int j) const ;friend class Aff_transformationH3<R>;private:  Vector_3  tv;};template < class R_ >class Aff_transformationH3  : public Handle_for_virtual< Aff_transformation_rep_baseH3<R_> >{  typedef typename R_::RT                   RT;  typedef typename R_::FT                   FT;  typedef typename R_::Point_3              Point_3;  typedef typename R_::Vector_3             Vector_3;  typedef typename R_::Direction_3          Direction_3;  typedef typename R_::Plane_3              Plane_3;  typedef typename R_::Aff_transformation_3 Aff_transformation_3;public:  typedef R_                R;  Aff_transformationH3();  // Identity  Aff_transformationH3(const Identity_transformation&);  // Translation  Aff_transformationH3(const Translation& , const Vector_3& v);  //  Scaling  Aff_transformationH3(const Scaling&, const RT& num, const RT& den);  //  General form  Aff_transformationH3(                  const RT& m00, const RT& m01, const RT& m02, const RT& m03,                  const RT& m10, const RT& m11, const RT& m12, const RT& m13,                  const RT& m20, const RT& m21, const RT& m22, const RT& m23,                                                               const RT& m33);  Aff_transformationH3(                  const RT& m00, const RT& m01, const RT& m02,                  const RT& m10, const RT& m11, const RT& m12,                  const RT& m20, const RT& m21, const RT& m22,                                                               const RT& m33);  Point_3  transform(const Point_3& p) const;  Vector_3  transform(const Vector_3& v) const;  Direction_3  transform(const Direction_3& d) const;  Plane_3  transform(const Plane_3& pl) const;  Aff_transformation_3  inverse()   const;  Aff_transformationH3<R>  transpose() const;  bool  is_even()   const;  bool  is_odd()    const;  FT  cartesian(int i, int j) const  { return this->Ptr()->cartesian(i,j); }  RT  homogeneous(int i, int j) const  { return this->Ptr()->homogeneous(i,j); }  FT  m(int i, int j) const  { return this->Ptr()->cartesian(i,j); }  RT  hm(int i, int j) const  { return this->Ptr()->homogeneous(i,j); }};template < class R >CGAL_KERNEL_INLINEAff_transformation_repH3<R>::Aff_transformation_repH3(                   const RT& m00, const RT& m01, const RT& m02, const RT& m03,                   const RT& m10, const RT& m11, const RT& m12, const RT& m13,                   const RT& m20, const RT& m21, const RT& m22, const RT& m23,                                                                const RT& m33)  :  t00(m00), t01(m01), t02(m02), t03(m03),     t10(m10), t11(m11), t12(m12), t13(m13),     t20(m20), t21(m21), t22(m22), t23(m23),                                   t33(m33){}template < class R >CGAL_KERNEL_INLINEtypename Aff_transformation_repH3<R>::Point_3Aff_transformation_repH3<R>::transform(const typename Aff_transformation_repH3<R>::Point_3& p) const{  return Point_3(t00 * p.hx() + t01 * p.hy() + t02 * p.hz() + t03 * p.hw(),                 t10 * p.hx() + t11 * p.hy() + t12 * p.hz() + t13 * p.hw(),                 t20 * p.hx() + t21 * p.hy() + t22 * p.hz() + t23 * p.hw(),                 t33 * p.hw());}template < class R >CGAL_KERNEL_INLINEtypename Aff_transformation_repH3<R>::Vector_3Aff_transformation_repH3<R>::transform(const typename Aff_transformation_repH3<R>::Vector_3& v) const{  return Vector_3(t00 * v.hx() + t01 * v.hy() + t02 * v.hz(),                  t10 * v.hx() + t11 * v.hy() + t12 * v.hz(),                  t20 * v.hx() + t21 * v.hy() + t22 * v.hz(),                  t33 * v.hw() );}template < class R >CGAL_KERNEL_INLINEtypename Aff_transformation_repH3<R>::Direction_3Aff_transformation_repH3<R>::transform(const typename Aff_transformation_repH3<R>::Direction_3& d) const{    if (t33 > RT(0))        return Direction_3(t00 * d.hx() + t01 * d.hy() + t02 * d.hz(),                           t10 * d.hx() + t11 * d.hy() + t12 * d.hz(),                           t20 * d.hx() + t21 * d.hy() + t22 * d.hz());    else        return - Direction_3(t00 * d.hx() + t01 * d.hy() + t02 * d.hz(),                             t10 * d.hx() + t11 * d.hy() + t12 * d.hz(),                             t20 * d.hx() + t21 * d.hy() + t22 * d.hz());}template < class R >CGAL_KERNEL_INLINEtypename Aff_transformation_repH3<R>::Plane_3Aff_transformation_repH3<R>::transform(const typename Aff_transformation_repH3<R>::Plane_3& pl) const{  if ( is_even() )  {      return Plane_3(               transform(pl.point() ),               transpose().inverse().transform(pl.orthogonal_direction() ));  }  else  {     return Plane_3(               transform(pl.point() ),               -(transpose().inverse().transform(pl.orthogonal_direction() )));  }}template < class R >CGAL_KERNEL_INLINEtypename Aff_transformation_repH3<R>::Aff_transformation_3Aff_transformation_repH3<R>::inverse() const{  typedef typename R::RT RT;  const RT  RT0(0);  return Aff_transformation_3(                           det3x3_by_formula( t11, t12, t13,                                                   t21, t22, t23,     // i 00                                                   RT0, RT0, t33 ),                        -  det3x3_by_formula( t01, t02, t03,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -