Thea
AffineTransform2.hpp
1 //============================================================================
2 //
3 // This file is part of the Thea toolkit.
4 //
5 // This software is distributed under the BSD license, as detailed in the
6 // accompanying LICENSE.txt file. Portions are derived from other works:
7 // their respective licenses and copyright information are reproduced in
8 // LICENSE.txt and/or in the relevant source files.
9 //
10 // Author: Siddhartha Chaudhuri
11 // First version: 2009
12 //
13 //============================================================================
14 
15 #ifndef __Thea_AffineTransform2_hpp__
16 #define __Thea_AffineTransform2_hpp__
17 
18 #include "Common.hpp"
19 #include "AffineTransformN.hpp"
20 
21 namespace Thea {
22 
24 template <typename T>
25 class /* THEA_API */ AffineTransformN<2, T> : public Internal::AffineTransformNBase<2, T>
26 {
27  private:
29 
30  public:
31  typedef typename BaseT::VectorT VectorT;
32  typedef typename BaseT::MatrixT MatrixT;
33 
36 
38  AffineTransformN(MatrixT const & linear_, VectorT const & translation_ = VectorT::Zero()) : BaseT(linear_, translation_) {}
39 
41  AffineTransformN(AffineTransformN const & src) : BaseT(src) {}
42 
47  AffineTransformN(VectorT const & x, VectorT const & y, VectorT const & translation_)
48  : BaseT((MatrixT() << x, y).finished(), translation_) {}
49 
51  AffineTransformN(T const & m00, T const & m01, T const & m02,
52  T const & m10, T const & m11, T const & m12)
53  : BaseT((MatrixT() << m00, m01, m10, m11).finished(), VectorT(m02, m12)) {}
54 
55  using BaseT::scaling;
56 
58  static AffineTransformN scaling(T const & sx, T const & sy)
59  {
60  return BaseT::scaling(VectorT(sx, sy));
61  }
62 
63  using BaseT::translation;
64 
66  static AffineTransformN translation(T const & tx, T const & ty)
67  {
68  return BaseT::translation(VectorT(tx, ty));
69  }
70 
72  static AffineTransformN rotation(Real radians)
73  {
74  return AffineTransformN(Math::rotation(radians), VectorT::Zero());
75  }
76 
77 }; // class AffineTransformN<2, T>
78 
79 #ifdef THEA_EXPORT_INSTANTIATION
80  template class THEA_API AffineTransformN<2, Real>;
81 #endif
82 
84 typedef AffineTransformN<2, Real> AffineTransform2;
85 
86 } // namespace Thea
87 
88 #endif
static AffineTransformT translation(VectorT const &v)
Construct a translation.
AffineTransformN()
Default constructor.
Root namespace for the Thea library.
AffineTransformN(VectorT const &x, VectorT const &y, VectorT const &translation_)
Construct from 2 basis vectors, specifying the linear transform, and a translation.
Matrix< 2, 2, T > rotation(T const &radians)
Matrix to rotate a 2D vector about the origin by an angle (in radians).
Definition: MatrixUtil.hpp:285
static AffineTransformN rotation(Real radians)
Construct a rotation specified by an angle (in radians) around the origin.
AffineTransformN()
Default constructor.
static AffineTransformT scaling(VectorT const &s)
Construct a scaling transform.
AffineTransformN(T const &m00, T const &m01, T const &m02, T const &m10, T const &m11, T const &m12)
Construct from a 2x3 array.
AffineTransformN(MatrixT const &linear_, VectorT const &translation_=VectorT::Zero())
Construct from a linear transform, followed by a translation.
static AffineTransformN translation(T const &tx, T const &ty)
Construct a translation.
static AffineTransformN scaling(T const &sx, T const &sy)
Construct a scaling transform.
AffineTransformN< 2, Real > AffineTransform2
The default affine transform class in real 2-space.
[Internal] Base class for affine transform in N-dimensional space, where N is any positive (non-zero)...
AffineTransformN(AffineTransformN const &src)
Copy constructor.
Vector< N, T > VectorT
N-dimensional vector.
An affine transform in N-dimensional space, where N is any positive (non-zero) integer and T is a fie...