Thea
AffineTransform3.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_AffineTransform3_hpp__
16 #define __Thea_AffineTransform3_hpp__
17 
18 #include "Common.hpp"
19 #include "AffineTransformN.hpp"
20 
21 namespace Thea {
22 
24 template <typename T>
25 class /* THEA_API */ AffineTransformN<3, T> : public Internal::AffineTransformNBase<3, 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 & z, VectorT const & translation_)
48  : BaseT((MatrixT() << x, y, z).finished(), translation_) {}
49 
51  AffineTransformN(T const & m00, T const & m01, T const & m02, T const & m03,
52  T const & m10, T const & m11, T const & m12, T const & m13,
53  T const & m20, T const & m21, T const & m22, T const & m23)
54  : BaseT((MatrixT() << m00, m01, m02, m10, m11, m12, m20, m21, m22).finished(), VectorT(m03, m13, m23)) {}
55 
56  using BaseT::scaling;
57 
59  static AffineTransformN scaling(T const & sx, T const & sy, T const & sz)
60  {
61  return BaseT::scaling(VectorT(sx, sy, sz));
62  }
63 
64  using BaseT::translation;
65 
67  static AffineTransformN translation(T const & tx, T const & ty, T const & tz)
68  {
69  return BaseT::translation(VectorT(tx, ty, tz));
70  }
71 
73  static AffineTransformN rotationAxisAngle(VectorT const & axis, Real radians)
74  {
75  return AffineTransformN(Math::rotationAxisAngle<T>(axis, radians), VectorT::Zero());
76  }
77 
81  static AffineTransformN rotationEulerAnglesXYZ(Real yaw_radians, Real pitch_radians, Real roll_radians)
82  {
83  return AffineTransformN(Math::rotationEulerAnglesXYZ<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
84  }
85 
89  static AffineTransformN rotationEulerAnglesXZY(Real yaw_radians, Real pitch_radians, Real roll_radians)
90  {
91  return AffineTransformN(Math::rotationEulerAnglesXZY<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
92  }
93 
97  static AffineTransformN rotationEulerAnglesYXZ(Real yaw_radians, Real pitch_radians, Real roll_radians)
98  {
99  return AffineTransformN(Math::rotationEulerAnglesYXZ<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
100  }
101 
105  static AffineTransformN rotationEulerAnglesYZX(Real yaw_radians, Real pitch_radians, Real roll_radians)
106  {
107  return AffineTransformN(Math::rotationEulerAnglesYZX<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
108  }
109 
113  static AffineTransformN rotationEulerAnglesZXY(Real yaw_radians, Real pitch_radians, Real roll_radians)
114  {
115  return AffineTransformN(Math::rotationEulerAnglesZXY<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
116  }
117 
121  static AffineTransformN rotationEulerAnglesZYX(Real yaw_radians, Real pitch_radians, Real roll_radians)
122  {
123  return AffineTransformN(Math::rotationEulerAnglesZYX<T>(yaw_radians, pitch_radians, roll_radians), VectorT::Zero());
124  }
125 
134  static AffineTransformN rotationArc(VectorT const & start_dir, VectorT const & end_dir, bool normalize_dirs = true)
135  {
136  return AffineTransformN(Math::rotationArc<T>(start_dir, end_dir, normalize_dirs), VectorT::Zero());
137  }
138 
139 }; // class AffineTransformN<3, T>
140 
141 #ifdef THEA_EXPORT_INSTANTIATION
142  template class THEA_API AffineTransformN<3, Real>;
143 #endif
144 
146 typedef AffineTransformN<3, Real> AffineTransform3;
147 
148 } // namespace Thea
149 
150 #endif
static AffineTransformT translation(VectorT const &v)
Construct a translation.
Root namespace for the Thea library.
AffineTransformN(AffineTransformN const &src)
Copy constructor.
AffineTransformN(VectorT const &x, VectorT const &y, VectorT const &z, VectorT const &translation_)
Construct from 3 basis vectors, specifying the linear transform, and a translation.
static AffineTransformN rotationArc(VectorT const &start_dir, VectorT const &end_dir, bool normalize_dirs=true)
Return the transformation corresponding to the rotation from one direction vector to another...
AffineTransformN()
Default constructor.
static AffineTransformT scaling(VectorT const &s)
Construct a scaling transform.
static AffineTransformN scaling(T const &sx, T const &sy, T const &sz)
Construct a scaling transform.
static AffineTransformN rotationEulerAnglesZYX(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the X axis by the roll angle, then the Y axis by the pitch angle, and finally the Z axis...
static AffineTransformN rotationAxisAngle(VectorT const &axis, Real radians)
Construct a rotation specified by an angle (in radians) around an axis.
static AffineTransformN rotationEulerAnglesYXZ(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the Z axis by the roll angle, then the X axis by the pitch angle, and finally the Y axis...
static AffineTransformN rotationEulerAnglesXZY(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the Y axis by the roll angle, then the Z axis by the pitch angle, and finally the X axis...
AffineTransformN< 3, Real > AffineTransform3
The default affine transform class in real 3-space.
AffineTransformN()
Default constructor.
[Internal] Base class for affine transform in N-dimensional space, where N is any positive (non-zero)...
static AffineTransformN rotationEulerAnglesZXY(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the Y axis by the roll angle, then the X axis by the pitch angle, and finally the Z axis...
Vector< N, T > VectorT
N-dimensional vector.
static AffineTransformN rotationEulerAnglesXYZ(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the Z axis by the roll angle, then the Y axis by the pitch angle, and finally the X axis...
static AffineTransformN rotationEulerAnglesYZX(Real yaw_radians, Real pitch_radians, Real roll_radians)
Rotate about the X axis by the roll angle, then the Z axis by the pitch angle, and finally the Y axis...
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, T const &tz)
Construct a translation.
AffineTransformN(T const &m00, T const &m01, T const &m02, T const &m03, T const &m10, T const &m11, T const &m12, T const &m13, T const &m20, T const &m21, T const &m22, T const &m23)
Construct from a 3x4 array.
An affine transform in N-dimensional space, where N is any positive (non-zero) integer and T is a fie...