00001 // This is core/vcsl/vcsl_perspective.cxx 00002 #include "vcsl_perspective.h" 00003 #include <vcl_cassert.h> 00004 00005 //--------------------------------------------------------------------------- 00006 // Is `this' invertible at time `time'? Never ! 00007 // REQUIRE: valid_time(time) 00008 //--------------------------------------------------------------------------- 00009 bool vcsl_perspective::is_invertible(double time) const 00010 { 00011 // require 00012 assert(valid_time(time)); 00013 return false; 00014 } 00015 00016 //--------------------------------------------------------------------------- 00017 // Set the focal in meters of a static perspective projection 00018 //--------------------------------------------------------------------------- 00019 void vcsl_perspective::set_static(double new_focal) 00020 { 00021 focal_.clear(); focal_.push_back(new_focal); 00022 vcsl_spatial_transformation::set_static(); 00023 } 00024 00025 //--------------------------------------------------------------------------- 00026 // Image of `v' by `this' 00027 // REQUIRE: is_valid() 00028 // REQUIRE: v.size()==3 and v[2]<0 00029 //--------------------------------------------------------------------------- 00030 vnl_vector<double> vcsl_perspective::execute(const vnl_vector<double> &v, 00031 double time) const 00032 { 00033 assert(is_valid()); 00034 assert(v.size()==3); 00035 assert(v[2]<0); 00036 00037 double f; 00038 double lambda; 00039 00040 vnl_vector<double> result(2); 00041 f=focal_value(time); 00042 lambda=-f/v[2]; 00043 result[0]=v[0]*lambda; 00044 result[1]=v[1]*lambda; 00045 return result; 00046 } 00047 00048 //--------------------------------------------------------------------------- 00049 // Image of `v' by the inverse of `this' 00050 // REQUIRE: is_valid() 00051 // REQUIRE: is_invertible(time) and v.size()==2 00052 // The first pre-condition is never true. You can not use this method 00053 //--------------------------------------------------------------------------- 00054 vnl_vector<double> vcsl_perspective::inverse(const vnl_vector<double> &v, 00055 double time) const 00056 { 00057 // require 00058 assert(is_valid()); 00059 assert((is_invertible(time))&&(v.size()==2)); 00060 return vnl_vector<double>(); // To avoid compilation warning/error message 00061 } 00062 00063 //--------------------------------------------------------------------------- 00064 // Compute the parameter at time `time' 00065 //--------------------------------------------------------------------------- 00066 double vcsl_perspective::focal_value(double time) const 00067 { 00068 if (this->duration()==0) // static 00069 return focal_[0]; 00070 else 00071 { 00072 int i=matching_interval(time); 00073 switch (interpolator_[i]) 00074 { 00075 case vcsl_linear: 00076 return lsi(focal_[i],focal_[i+1],i,time); 00077 case vcsl_cubic: 00078 assert(!"vcsl_cubic net yet implemented"); 00079 break; 00080 case vcsl_spline: 00081 assert(!"vcsl_spline net yet implemented"); 00082 break; 00083 default: 00084 assert(!"This is impossible"); 00085 break; 00086 } 00087 } 00088 return 0.0; // never reached if asserts are in effect 00089 }