vcsl_perspective.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_perspective.cxx
2 #include "vcsl_perspective.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'? Never !
10 // REQUIRE: valid_time(time)
11 //---------------------------------------------------------------------------
12 bool vcsl_perspective::is_invertible(double time) const
13 {
14  // require
15  assert(valid_time(time));
16  return false;
17 }
18 
19 //---------------------------------------------------------------------------
20 // Set the focal in meters of a static perspective projection
21 //---------------------------------------------------------------------------
22 void vcsl_perspective::set_static(double new_focal)
23 {
24  focal_.clear(); focal_.push_back(new_focal);
26 }
27 
28 //---------------------------------------------------------------------------
29 // Image of `v' by `this'
30 // REQUIRE: is_valid()
31 // REQUIRE: v.size()==3 and v[2]<0
32 //---------------------------------------------------------------------------
34  double time) const
35 {
36  assert(is_valid());
37  assert(v.size()==3);
38  assert(v[2]<0);
39 
40  double f;
41  double lambda;
42 
43  vnl_vector<double> result(2);
44  f=focal_value(time);
45  lambda=-f/v[2];
46  result[0]=v[0]*lambda;
47  result[1]=v[1]*lambda;
48  return result;
49 }
50 
51 //---------------------------------------------------------------------------
52 // Image of `v' by the inverse of `this'
53 // REQUIRE: is_valid()
54 // REQUIRE: is_invertible(time) and v.size()==2
55 // The first pre-condition is never true. You can not use this method
56 //---------------------------------------------------------------------------
58  double time) const
59 {
60  // require
61  assert(is_valid());
62  assert((is_invertible(time))&&(v.size()==2));
63  return vnl_vector<double>(); // To avoid compilation warning/error message
64 }
65 
66 //---------------------------------------------------------------------------
67 // Compute the parameter at time `time'
68 //---------------------------------------------------------------------------
69 double vcsl_perspective::focal_value(double time) const
70 {
71  if (this->duration()==0) // static
72  return focal_[0];
73  else
74  {
75  int i=matching_interval(time);
76  switch (interpolator_[i])
77  {
78  case vcsl_linear:
79  return lsi(focal_[i],focal_[i+1],i,time);
80  case vcsl_cubic:
81  assert(!"vcsl_cubic net yet implemented");
82  break;
83  case vcsl_spline:
84  assert(!"vcsl_spline net yet implemented");
85  break;
86  default:
87  assert(!"This is impossible");
88  break;
89  }
90  }
91  return 0.0; // never reached if asserts are in effect
92 }
unsigned int duration() const
Return the time duration.
vnl_vector< double > inverse(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by the inverse of ‘this’.
double lsi(double v0, double v1, int index, double time) const
Linear interpolation on scalar values.
bool is_invertible(double time) const override
Is ‘this’ invertible at time ‘time’? Never !.
double focal_value(double time) const
Compute the parameter at time ‘time’.
Perspective projection transformation.
std::vector< vcsl_interpolator > interpolator_
void set_static()
Empty the time clock and interpolators, thereby making the transf static.
#define v
bool is_valid() const override
Is ‘this’ correctly set ?.
list_of_scalars focal_
Angle variation along the time.
vnl_vector< double > execute(const vnl_vector< double > &v, double time) const override
Image of ‘v’ by ‘this’.
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 ?.