vcsl_spatial_transformation.h
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_spatial_transformation.h
2 #ifndef vcsl_spatial_transformation_h_
3 #define vcsl_spatial_transformation_h_
4 //:
5 // \file
6 // \author Francois BERTEL
7 // \brief Transformation between 2 spatial coordinate systems
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 - added lmi() as it is used in vcsl_matrix.cxx
14 // 2002/01/22 Peter Vanroose - return type of lqi(), lvi(), execute() and inverse() changed to non-ptr
15 // 2002/01/28 Peter Vanroose - std::vector members beat_ and interpolator_ changed to non-ptr
16 // 2004/09/10 Peter Vanroose - Added explicit copy constructor (ref_count !)
17 // 2004/09/17 Peter Vanroose - made beat() and interpolators() non-virtual: they just return a member and should not be overloaded
18 // \endverbatim
19 
20 #include <vector>
22 
23 #include <vbl/vbl_ref_count.h>
24 #ifdef _MSC_VER
25 # include <vcl_msvc_warnings.h>
26 #endif
27 #include <vnl/vnl_vector.h>
28 #include <vnl/vnl_quaternion.h>
29 
30 typedef std::vector<double> list_of_scalars;
31 typedef std::vector<vnl_vector<double> > list_of_vectors;
32 
34 {
38 };
39 
40 //: Transformation between 2 spatial coordinate systems
41 // A spatial transformation can be static or dynamic
43 {
44  //***************************************************************************
45  // Constructors/Destructor
46  //***************************************************************************
47 
48  protected:
49  // Default constructor. Do nothing
50  vcsl_spatial_transformation() = default;
51 
52  public:
53  // Copy constructor
56 
57  // Destructor. Do nothing
58  ~vcsl_spatial_transformation() override = default;
59 
60  //***************************************************************************
61  // Status report
62  //***************************************************************************
63 
64  //: Return the list of time clocks
65  std::vector<double> beat() const { return beat_; }
66 
67  //: Return the time duration
68  unsigned int duration() const { return (unsigned int)(beat_.size()); }
69 
70  //: Return the list of interpolators
71  std::vector<vcsl_interpolator> interpolators() const { return interpolator_; }
72 
73  //: Is `time' between the two time bounds ?
74  bool valid_time(double time) const;
75 
76  //: Is `this' invertible at time `time'?
77  // REQUIRE: valid_time(time)
78  virtual bool is_invertible(double time) const=0;
79 
80  //: Is `this' correctly set ?
81  virtual bool is_valid() const
82  { return (duration()==0&&interpolator_.size()==0) ||
83  (duration()==interpolator_.size()+1); }
84 
85  //***************************************************************************
86  // Basic operations
87  //***************************************************************************
88 
89  //: Return the index of the beat inferior or equal to `time'
90  // REQUIRE: valid_time(time)
91  int matching_interval(double time) const;
92 
93  //: Image of `v' by `this'
94  // REQUIRE: is_valid()
96  double time) const=0;
97 
98  //: Image of `v' by the inverse of `this'
99  // REQUIRE: is_invertible(time)
100  // REQUIRE: is_valid()
102  double time) const=0;
103 
104  //***************************************************************************
105  // Status setting
106  //***************************************************************************
107 
108  //: Set the list of time clocks
109  void set_beat(std::vector<double> const& new_beat) { beat_=new_beat; }
110 
111  //: Set the list of interpolators
112  void set_interpolators(std::vector<vcsl_interpolator> const& i) { interpolator_=i; }
113 
114  //: Empty the time clock and interpolators, thereby making the transf static
115  void set_static();
116 
117  //***************************************************************************
118  // Interpolators
119  //***************************************************************************
120 
121  //: Linear interpolation on scalar values
122  double lsi(double v0,
123  double v1,
124  int index,
125  double time) const;
126 
127  //: Linear interpolation on vnl_vectors
129  const vnl_vector<double> &v1,
130  int index,
131  double time) const;
132 
133  //: Linear interpolation on vnl_matrices
135  const vnl_matrix<double> &m1,
136  int index,
137  double time) const;
138 
139  //: Linear interpolation on quaternions
141  const vnl_quaternion<double> &v1,
142  int index,
143  double time) const;
144 
145  protected:
146  //: List of time clocks
147  std::vector<double> beat_;
148  std::vector<vcsl_interpolator> interpolator_;
149 };
150 
151 #endif // vcsl_spatial_transformation_h_
unsigned int duration() const
Return the time duration.
void set_beat(std::vector< double > const &new_beat)
Set the list of time clocks.
std::vector< double > beat() const
Return the list of time clocks.
Transformation between 2 spatial coordinate systems.
vnl_vector< double > lvi(const vnl_vector< double > &v0, const vnl_vector< double > &v1, int index, double time) const
Linear interpolation on vnl_vectors.
vnl_quaternion< double > lqi(const vnl_quaternion< double > &v0, const vnl_quaternion< double > &v1, int index, double time) const
Linear interpolation on quaternions.
std::vector< vnl_vector< double > > list_of_vectors
double lsi(double v0, double v1, int index, double time) const
Linear interpolation on scalar values.
vnl_matrix< double > lmi(const vnl_matrix< double > &m0, const vnl_matrix< double > &m1, int index, double time) const
Linear interpolation on vnl_matrices.
std::vector< double > beat_
List of time clocks.
vcsl_spatial_transformation(vcsl_spatial_transformation const &x)
virtual vnl_vector< double > inverse(const vnl_vector< double > &v, double time) const =0
Image of ‘v’ by the inverse of ‘this’.
std::vector< vcsl_interpolator > interpolator_
virtual vnl_vector< double > execute(const vnl_vector< double > &v, double time) const =0
Image of ‘v’ by ‘this’.
void set_interpolators(std::vector< vcsl_interpolator > const &i)
Set the list of interpolators.
void set_static()
Empty the time clock and interpolators, thereby making the transf static.
virtual bool is_invertible(double time) const =0
Is ‘this’ invertible at time ‘time’?.
virtual bool is_valid() const
Is ‘this’ correctly set ?.
std::vector< vcsl_interpolator > interpolators() const
Return the list of interpolators.
~vcsl_spatial_transformation() override=default
int matching_interval(double time) const
Return the index of the beat inferior or equal to ‘time’.
bool valid_time(double time) const
Is ‘time’ between the two time bounds ?.
std::vector< double > list_of_scalars