Thea
CoordinateFrame2.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_CoordinateFrame2_hpp__
16 #define __Thea_CoordinateFrame2_hpp__
17 
18 #include "Common.hpp"
19 #include "CoordinateFrameN.hpp"
20 
21 namespace Thea {
22 
24 template <typename T>
25 class /* THEA_API */ CoordinateFrameN<2, T> : public Internal::CoordinateFrameNBase<2, T>
26 {
27  private:
29 
30  public:
31  typedef typename BaseT::RigidTransformT RigidTransformT;
32  typedef typename BaseT::VectorT VectorT;
33  typedef typename BaseT::MatrixT MatrixT;
34 
37 
39  CoordinateFrameN(RigidTransformT const & src) : BaseT(src) {}
40 
42  CoordinateFrameN(VectorT const & eye, VectorT const & center)
43  {
44  set(eye, center);
45  }
46 
48  void set(VectorT const & eye, VectorT const & center)
49  {
50  VectorT f = (center - eye).normalized();
51  this->_setRotation((MatrixT() << f[0], -f[1], f[1], f[0]).finished());
52  this->setTranslation(eye);
53  }
54 
55  private:
56  // Hide these functions from the default interface
57  static RigidTransformT rotation(Real radians) { return RigidTransformT(); }
58 
59 }; // class CoordinateFrameN<2, T>
60 
61 #ifdef THEA_EXPORT_INSTANTIATION
62  template class THEA_API CoordinateFrameN<2, Real>;
63 #endif
64 
66 typedef CoordinateFrameN<2, Real> CoordinateFrame2;
67 
68 } // namespace Thea
69 
70 #endif
[Internal] Base class for a coordinate frame in N-space, defined by N orthonormal vectors...
Root namespace for the Thea library.
CoordinateFrameN(RigidTransformT const &src)
Construct from a rigid transform.
CoordinateFrameN(VectorT const &eye, VectorT const &center)
Construct from a viewing position (eye) and a look-at position (center).
A rigid transformation in N-space, consisting of a rotation followed by a translation.
CoordinateFrameN()
Default constructor.
void _setRotation(MatrixT const &rot)
Set the rotation matrix (use with caution since it can break the rigidity guarantee).
CoordinateFrameN< 2, Real > CoordinateFrame2
The default coordinate frame class in real 2-space.
A coordinate frame in N-space, defined by N orthonormal vectors.
void setTranslation(VectorT const &translation_)
Set translation component.