vcsl_composition.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_composition.cxx
2 #include "vcsl_composition.h"
3 #include <cassert>
4 #ifdef _MSC_VER
5 # include <vcl_msvc_warnings.h>
6 #endif
7 
8 //---------------------------------------------------------------------------
9 // Is `this' invertible at time `time'?
10 // REQUIRE: valid_time(time)
11 //---------------------------------------------------------------------------
12 bool vcsl_composition::is_invertible(double time) const
13 {
14  // require
15  assert(valid_time(time));
16 
17  std::vector<vcsl_spatial_transformation_sptr>::const_iterator i;
18 
19  bool result=true;
20  for (i=transformations_.begin();result&&i!=transformations_.end();++i)
21  result=(*i)->is_invertible(time);
22 
23  return result;
24 }
25 
26 //---------------------------------------------------------------------------
27 // Is `this' correctly set ?
28 //---------------------------------------------------------------------------
30 {
31  std::vector<vcsl_spatial_transformation_sptr>::const_iterator i;
32  for (i=transformations_.begin(); i!=transformations_.end(); ++i)
33  if (!(*i)->is_valid()) return false;
34 
35  return true;
36 }
37 
38 //---------------------------------------------------------------------------
39 // Image of `v' by `this'
40 // REQUIRE: is_valid()
41 //---------------------------------------------------------------------------
43  double time) const
44 {
45  // require
46  assert(is_valid());
47 
48  vnl_vector<double> result = v;
49 
50  std::vector<vcsl_spatial_transformation_sptr>::const_iterator i;
51  for (i=transformations_.begin();i!=transformations_.end();++i)
52  result=(*i)->execute(result,time);
53  return result;
54 }
55 
56 //---------------------------------------------------------------------------
57 // Image of `v' by the inverse of `this'
58 // REQUIRE: is_valid()
59 // REQUIRE: is_invertible(time)
60 //---------------------------------------------------------------------------
62  double time) const
63 {
64  // require
65  assert(is_valid());
66  assert(is_invertible(time));
67 
68  vnl_vector<double> result = v;
69 
70  std::vector<vcsl_spatial_transformation_sptr>::const_reverse_iterator i;
71  for (i=transformations_.rbegin();!(i==transformations_.rend());++i)
72  result=(*i)->inverse(result,time);
73  return result;
74 }
vnl_vector< double > inverse(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by the inverse of ‘this’.
bool is_valid() const override
Is ‘this’ correctly set ?.
Composition of transformations.
bool is_invertible(double time) const override
Is ‘this’ invertible at time ‘time’?.
#define v
std::vector< vcsl_spatial_transformation_sptr > transformations_
bool valid_time(double time) const
Is ‘time’ between the two time bounds ?.
vnl_vector< double > execute(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by ‘this’.