xc
Trf3d.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 //Trf3d.h
22 //Three dimensional transformation.
23 
24 #ifndef TRF3D_H
25 #define TRF3D_H
26 
27 #include "Trf.h"
28 #include "../cgal_types.h"
29 
30 class Pos3d;
31 class Vector3d;
32 class Pos3dArray;
33 class Pos3dArray3d;
34 
35 
37 //
39 class Trf3d: public Trf
40  {
41  private:
42  CGTrfAfin_3 cgtrf;
43  Trf3d(const CGTrfAfin_3 &t)
44  : Trf(), cgtrf(t) {}
45  protected:
46  Trf3d(const CGAL::Translation &tr,const Vector3d &v);
47  //Trf3d(const CGAL::Rotation &rot,const GEOM_FT &seno,const GEOM_FT &coseno);
48  Trf3d(const CGAL::Scaling &sc,const GEOM_FT &factor_escala);
49  explicit Trf3d(const CGAL::Identity_transformation &i);
50  public:
51  Trf3d(void)
52  : Trf(), cgtrf(CGAL::Identity_transformation()) {}
53  Trf3d( const GEOM_FT & m00,const GEOM_FT & m01,const GEOM_FT & m02,const GEOM_FT & m03,
54  const GEOM_FT & m10,const GEOM_FT & m11,const GEOM_FT & m12,const GEOM_FT & m13,
55  const GEOM_FT & m20,const GEOM_FT & m21,const GEOM_FT & m22,const GEOM_FT & m23);
56  //Trf3d Inversa(void) const;
57  //Return the inverse transformation.
58  //@brief Return the (i,j) componet of the transformation matrix expressed in
59  // cartesian coordinates.
60  // - -
61  // | m11 m12 m13 |
62  // | m21 m22 m23 |
63  // | 0 0 1 |
64  // - -
65  virtual GEOM_FT Cartesianas(const size_t &i,const size_t &j) const
66  { return cgtrf.m(i-1,j-1); }
67 
68  //@brief Return the (i,j) componet of the transformation matrix expressed in
69  // homogeneous coordinates.
70  // - -
71  // | m11 m12 m13 |
72  // | m21 m22 m23 |
73  // | 0 0 hw |
74  // - -
75  virtual GEOM_FT Homogeneas(const size_t &i,const size_t &j) const
76  { return cgtrf.hm(i-1,j-1); }
77  void putHomogenousMatrix(const FT_matrix &mh);
78  virtual FT_matrix Cartesianas(void) const;
79  virtual FT_matrix Homogeneas(void) const;
80  Pos3d Transform(const Pos3d &p) const;
81  Vector3d Transform(const Vector3d &v) const;
82  template <class InputIterator>
83  void Transform(InputIterator first,InputIterator last) const;
84  void Transform(Pos3dArray &m) const;
85  const Pos3dArray &Transform(const Pos3dArray &m) const;
86  void Transform(Pos3dArray3d &m) const;
87  const Pos3dArray3d &Transform(const Pos3dArray3d &m) const;
88  Pos3d operator()(const Pos3d &p) const;
89  Vector3d operator()(const Vector3d &v) const;
90  Pos3dArray operator()(const Pos3dArray &m) const;
91  friend Trf3d operator*(const Trf3d &a,const Trf3d &b);
92  friend Trf3d giroX3d(const double &ang_rad);
93  friend Trf3d giroY3d(const double &ang_rad);
94  friend Trf3d giroZ3d(const double &ang_rad);
95  virtual ~Trf3d(void) {}
96  };
97 
98 Trf3d giroX3d(const double &ang_rad);
99 Trf3d giroY3d(const double &ang_rad);
100 Trf3d giroZ3d(const double &ang_rad);
101 
102 inline Trf3d giroXYZ3d(const double &rx,const double &ry,const double &rz)
103  { return giroZ3d(rz) * giroY3d(ry) * giroX3d(rx); }
104 
105 template <class InputIterator>
106 void Trf3d::Transform(InputIterator first,InputIterator last) const
107  {
108  for(InputIterator i= first;i!=last;i++)
109  (*i)= Transform(*i);
110  }
111 
112 #endif
virtual FT_matrix Cartesianas(void) const
Return the transformation matrix en cartesianas.
Definition: Trf3d.cc:113
Array of positions in a three-dimensional space.
Definition: Pos3dArray.h:38
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: Trf3d.h:65
Base class for coordinate transformation.
Definition: Trf.h:36
Pos3d operator()(const Pos3d &p) const
Transform the point.
Definition: Trf3d.cc:180
Pos3d Transform(const Pos3d &p) const
Return the transformed of the point.
Definition: Trf3d.cc:135
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: Trf3d.h:75
virtual FT_matrix Homogeneas(void) const
Return the transformation matrix en homogéneas.
Definition: Trf3d.cc:124
Position array in a three-dimensional space.
Definition: Pos3dArray3d.h:37
Posición en tres dimensiones.
Definition: Pos3d.h:44
Three-dimensional transformation.
Definition: Trf3d.h:39
Matrix which components are GEOM_FT numbers.
Definition: FT_matrix.h:40
Vector en tres dimensiones.
Definition: Vector3d.h:39