vcsl_rotation.h
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_rotation.h
2 #ifndef vcsl_rotation_h_
3 #define vcsl_rotation_h_
4 //:
5 // \file
6 // \brief Rotation transformation (either 2D or 3D)
7 // \author Francois BERTEL
8 //
9 // \verbatim
10 // Modifications
11 // 2000/06/28 Francois BERTEL Creation. Adapted from IUE
12 // 2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
13 // 2002/01/22 Peter Vanroose - return type of quaternion(), execute() and inverse() changed to non-ptr
14 // 2002/01/28 Peter Vanroose - std::vector members angle_ and axis_ changed to non-ptr
15 // 2004/09/17 Peter Vanroose - made angle() non-virtual - it just returns a member and should not be overloaded
16 // \endverbatim
17 
20 #include <vnl/vnl_quaternion.h>
21 
22 //: Rotation transformation (either 2D or 3D).
23 // A rotation rotates a point around an axis passing through the origin.
24 // For a more general rotation (affine rotation or displacement), see
25 // the derived class \b vcsl_displacement
28 {
29  public:
30  //***************************************************************************
31  // Constructors/Destructor
32  //***************************************************************************
33 
34  //: Default constructor. Sets 3D rotation mode
35  vcsl_rotation() : mode_2d_(false) {}
36 
37  // Destructor
38  ~vcsl_rotation() override = default;
39 
40  //***************************************************************************
41  // Status report
42  //***************************************************************************
43 
44  //: Is `this' invertible at time `time'?
45  // REQUIRE: valid_time(time)
46  // Pure virtual function of vcsl_spatial_transformation
47  bool is_invertible(double /*time*/) const override { return true; }
48 
49  //: Is `this' correctly set ?
50  // Virtual function of vcsl_spatial_transformation
51  bool is_valid() const override
53  this->duration()==axis_.size() &&
54  this->duration()==angle_.size(); }
55 
56  //: Are `new_vector' a list of unit vectors ?
57  bool are_unit_axes(list_of_vectors const& new_axis) const;
58 
59  //: Is `this' a 2D rotation ?
60  bool is_2d() const { return mode_2d_; }
61 
62  //: Is `this' a 3D rotation ?
63  bool is_3d() const { return !mode_2d_; }
64 
65  //***************************************************************************
66  // Status setting
67  //***************************************************************************
68 
69  //: Set `this' as a 2D rotation
70  void set_2d() { mode_2d_=true; }
71 
72  //: Set `this' as a 3D rotation
73  void set_3d() { mode_2d_=false; }
74 
75  //***************************************************************************
76  // Transformation parameters
77  //***************************************************************************
78 
79  //: Set the parameters of a static 2D rotation
80  void set_static_2d(double new_angle);
81 
82  //: Set the parameters of a static rotation
83  void set_static(double new_angle, vnl_vector<double> const& new_axis);
84 
85  //: Set the angle variation along the time in radians
86  void set_angle(list_of_scalars const& new_angle) { angle_=new_angle; }
87 
88  //: Return the angle variation along the time in radians
89  list_of_scalars angle() const { return angle_; }
90 
91  //: Set the direction vector variation along the time
92  // REQUIRE: are_unit_vectors(new_vector)
93  void set_axis(list_of_vectors const& new_axis);
94 
95  //: Return the direction variation along the time
96  list_of_vectors axis() const { return axis_; }
97 
98  //***************************************************************************
99  // Basic operations
100  //***************************************************************************
101 
102  //: Image of `v' by `this'
103  // REQUIRE: is_valid()
104  // REQUIRE: (is_2d()&&v.size()==2)||(is_3d()&&v.size()==3)
105  // Pure virtual function of vcsl_spatial_transformation
107  double time) const override;
108 
109  //: Image of `v' by the inverse of `this'
110  // REQUIRE: is_valid()
111  // REQUIRE: is_invertible(time)
112  // REQUIRE (is_2d()&&v.size()==2)||(is_3d()&&v.size()==3)
113  // Pure virtual function of vcsl_spatial_transformation
115  double time) const override;
116 
117  protected:
118  //: Compute the value of the quaternion at time `time'
119  vnl_quaternion<double> quaternion(double time) const;
120 
121  //: False if `this' is a 3D rotation, true if `this' is a 2D rotation
122  bool mode_2d_;
123 
124  //: Angle variation along the time in radians
126 
127  //: Direction vector variation along the time
129 };
130 
131 #endif // vcsl_rotation_h_
unsigned int duration() const
Return the time duration.
vnl_vector< double > execute(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by ‘this’.
void set_angle(list_of_scalars const &new_angle)
Set the angle variation along the time in radians.
Definition: vcsl_rotation.h:86
Transformation between 2 spatial coordinate systems.
vcsl_rotation()
Default constructor. Sets 3D rotation mode.
Definition: vcsl_rotation.h:35
std::vector< vnl_vector< double > > list_of_vectors
list_of_scalars angle_
Angle variation along the time in radians.
bool mode_2d_
False if ‘this’ is a 3D rotation, true if ‘this’ is a 2D rotation.
list_of_vectors axis_
Direction vector variation along the time.
vnl_vector< double > inverse(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by the inverse of ‘this’.
list_of_vectors axis() const
Return the direction variation along the time.
Definition: vcsl_rotation.h:96
Transformation between 2 spatial coordinate systems.
list_of_scalars angle() const
Return the angle variation along the time in radians.
Definition: vcsl_rotation.h:89
void set_static()
Empty the time clock and interpolators, thereby making the transf static.
bool is_invertible(double) const override
Is ‘this’ invertible at time ‘time’?.
Definition: vcsl_rotation.h:47
bool is_2d() const
Is ‘this’ a 2D rotation ?.
Definition: vcsl_rotation.h:60
bool are_unit_axes(list_of_vectors const &new_axis) const
Are ‘new_vector’ a list of unit vectors ?.
void set_2d()
Set ‘this’ as a 2D rotation.
Definition: vcsl_rotation.h:70
void set_static_2d(double new_angle)
Set the parameters of a static 2D rotation.
virtual bool is_valid() const
Is ‘this’ correctly set ?.
void set_axis(list_of_vectors const &new_axis)
Set the direction vector variation along the time.
void set_3d()
Set ‘this’ as a 3D rotation.
Definition: vcsl_rotation.h:73
~vcsl_rotation() override=default
bool is_3d() const
Is ‘this’ a 3D rotation ?.
Definition: vcsl_rotation.h:63
vnl_quaternion< double > quaternion(double time) const
Compute the value of the quaternion at time ‘time’.
std::vector< double > list_of_scalars
Rotation transformation (either 2D or 3D).
Definition: vcsl_rotation.h:26
bool is_valid() const override
Is ‘this’ correctly set ?.
Definition: vcsl_rotation.h:51