xc
Trf2d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //Trf2d.h
22 //Two-dimensional transformations.
23 
24 #ifndef TRF2D_H
25 #define TRF2D_H
26 
27 #include "Trf.h"
28 #include "../cgal_types.h"
29 #include "utility/geom/d2/GeomObj2d.h"
30 
31 class Pos2d;
32 class Vector2d;
33 class Line2d;
34 
35 
36 
38 //
40 class Trf2d: public Trf
41  {
42  private:
43  CGTrfAfin_2 cgtrf;
44  Trf2d(const CGTrfAfin_2 &t)
45  : Trf(), cgtrf(t) {}
46  protected:
47  Trf2d(const CGAL::Translation &tr,const Vector2d &v);
48  Trf2d(const CGAL::Rotation &rot,const GEOM_RT &seno,const GEOM_RT &coseno);
49 /* //Trf2d(const CGAL::Reflection &ref,const Line2d &r); */
50  Trf2d(const CGAL::Scaling &sc,const GEOM_FT &factor_escala);
51  explicit Trf2d(const CGAL::Identity_transformation &i);
52 
53  CGPoint_2 Transform(const CGPoint_2 &cgpt2) const;
54  public:
55  Trf2d(void)
56  : Trf(), cgtrf(CGAL::Identity_transformation()) {}
57 /* Trf2d( const GEOM_RT & m00,const GEOM_RT & m01,const GEOM_RT & m02, */
58 /* const GEOM_RT & m10,const GEOM_RT & m11,const GEOM_RT & m12, */
59 /* const GEOM_RT & hw = GEOM_RT(1.0)); */
60  Trf2d( const GEOM_FT & m00,const GEOM_FT & m01,const GEOM_FT & m02,
61  const GEOM_FT & m10,const GEOM_FT & m11,const GEOM_FT & m12);
62  Trf2d(const Trf2d &other)
63  : Trf(other), cgtrf(other.cgtrf) {}
64  Trf2d &operator=(const Trf2d &other)
65  {
66  Trf::operator=(other);
67  cgtrf= other.cgtrf;
68  return *this;
69  }
70  //Return the inverse transformation.
71  //Trf2d Inversa(void) const;
72 
73  //@brief Return the (i,j) componet of the transformation matrix expressed in
74  // cartesian coordinates.
75  // - -
76  // | m11 m12 m13 |
77  // | m21 m22 m23 |
78  // | 0 0 1 |
79  // - -
80  virtual GEOM_FT Cartesianas(const size_t &i,const size_t &j) const
81  { return cgtrf.m(i-1,j-1); }
82 
83  //@brief Return the (i,j) componet of the transformation matrix expressed in
84  // homogeneous coordinates.
85  // - -
86  // | m11 m12 m13 |
87  // | m21 m22 m23 |
88  // | 0 0 hw |
89  // - -
90  virtual GEOM_FT Homogeneas(const size_t &i,const size_t &j) const
91  { return cgtrf.hm(i-1,j-1); }
92  virtual FT_matrix Cartesianas(void) const;
93  virtual FT_matrix Homogeneas(void) const;
94  Pos2d Transform(const Pos2d &p) const;
95  Vector2d Transform(const Vector2d &v) const;
96  template <class InputIterator>
97  void Transform(InputIterator first,InputIterator last) const;
98  GeomObj::list_Pos2d Transform(const GeomObj::list_Pos2d &lp2d) const;
99  Pos2d operator()(const Pos2d &p) const;
100  Vector2d operator()(const Vector2d &v) const;
101  GeomObj::list_Pos2d operator()(const GeomObj::list_Pos2d &lp2d) const;
102  friend Trf2d operator*(const Trf2d &a,const Trf2d &b);
103  virtual ~Trf2d(void) {}
104  };
105 
106 template <class InputIterator>
107 void Trf2d::Transform(InputIterator first,InputIterator last) const
108  {
109  for(InputIterator i= first;i!=last;i++)
110  (*i)= Transform(*i);
111  }
112 
113 #endif
Base class for position lists.
Definition: PolyPos.h:35
Posición en dos dimensiones.
Definition: Pos2d.h:41
virtual FT_matrix Homogeneas(void) const
Return the transformation matrix expressed in homogeneous coordinates.
Definition: Trf2d.cc:106
Base class for coordinate transformation.
Definition: Trf.h:36
Line in a two-dimensional space.
Definition: Line2d.h:61
EntityWithOwner & operator=(const EntityWithOwner &)
Assignment operator.
Definition: EntityWithOwner.cc:53
Base class for two-dimensional transformations.
Definition: Trf2d.h:40
virtual FT_matrix Cartesianas(void) const
Return the transformation matrix expressed in cartesian coordinates.
Definition: Trf2d.cc:96
Vector en dos dimensiones.
Definition: Vector2d.h:40
virtual GEOM_FT Cartesianas(const size_t &i, const size_t &j) const
Return the (i,j) component of the transformation matrix expressed in cartesian coordinates.
Definition: Trf2d.h:80
Matrix which components are GEOM_FT numbers.
Definition: FT_matrix.h:40
virtual GEOM_FT Homogeneas(const size_t &i, const size_t &j) const
Return the (i,j) component of the transformation matrix expressed in homogeneous coordinates.
Definition: Trf2d.h:90