core/vcsl/vcsl_perspective.h
Go to the documentation of this file.
00001 // This is core/vcsl/vcsl_perspective.h
00002 #ifndef vcsl_perspective_h_
00003 #define vcsl_perspective_h_
00004 //:
00005 // \file
00006 // \brief Perspective projection transformation
00007 // \author François BERTEL
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   2000/08/23 François BERTEL Creation.
00012 //   2001/04/10 Ian Scott (Manchester) Converted perceps header to doxygen
00013 //   2002/01/22 Peter Vanroose - return type of execute() and inverse() changed to non-ptr
00014 //   2002/01/28 Peter Vanroose - vcl_vector member focal_ changed to non-ptr
00015 //   2004/09/17 Peter Vanroose - made focal() non-virtual - it just returns a member and should not be overloaded
00016 // \endverbatim
00017 
00018 #include <vcsl/vcsl_spatial_transformation.h>
00019 #include <vcsl/vcsl_perspective_sptr.h>
00020 
00021 //: Perspective projection transformation
00022 // This is a perspective projection from a 3D cartesian coordinate system to a
00023 // 2D cartesian coordinate system, parametrized by the focal expressed in
00024 // meters. The projection is along the z axis. The center of the projection is
00025 // the origin of the 3D frame. The projection plane is in the half-space z<0.
00026 class vcsl_perspective
00027   :public vcsl_spatial_transformation
00028 {
00029   //***************************************************************************
00030   // Constructors/Destructor
00031   //***************************************************************************
00032 
00033   // Default constructor
00034   vcsl_perspective() {}
00035 
00036  public:
00037   // Destructor
00038   virtual ~vcsl_perspective() {}
00039 
00040   //***************************************************************************
00041   // Status report
00042   //***************************************************************************
00043 
00044   //: Is `this' invertible at time `time'? Never !
00045   //  REQUIRE: valid_time(time)
00046   // Pure virtual function of vcsl_spatial_transformation
00047   virtual bool is_invertible(double time) const;
00048 
00049   //: Is `this' correctly set ?
00050   // Virtual function of vcsl_spatial_transformation
00051   virtual bool is_valid() const
00052   { return vcsl_spatial_transformation::is_valid() &&
00053            ((this->duration()==0&&focal_.size()==1) ||
00054             this->duration()==focal_.size()); }
00055 
00056   //***************************************************************************
00057   // Transformation parameters
00058   //***************************************************************************
00059 
00060   //: Set the focal in meters of a static perspective projection
00061   void set_static(double new_focal);
00062 
00063   //: Set the focal variation along the time in meters
00064   void set_focal(list_of_scalars const& new_focal) { focal_=new_focal; }
00065 
00066   //: Return the focal variation along the time in meters
00067   list_of_scalars focal() const { return focal_; }
00068 
00069   //***************************************************************************
00070   // Basic operations
00071   //***************************************************************************
00072 
00073   //: Image of `v' by `this'
00074   //  REQUIRE: is_valid()
00075   //  REQUIRE: v.size()==3
00076   // Pure virtual function of vcsl_spatial_transformation
00077   virtual vnl_vector<double> execute(const vnl_vector<double> &v,
00078                                      double time) const;
00079 
00080   //: Image of `v' by the inverse of `this'
00081   //  REQUIRE: is_valid()
00082   //  REQUIRE: is_invertible(time) and v.size()==2
00083   //  The first pre-condition is never true. You can not use this method
00084   // Pure virtual function of vcsl_spatial_transformation
00085   virtual vnl_vector<double> inverse(const vnl_vector<double> &v,
00086                                      double time) const;
00087 
00088  protected:
00089 
00090   //: Compute the parameter at time `time'
00091   double focal_value(double time) const;
00092 
00093   //: Angle variation along the time
00094   list_of_scalars focal_;
00095 };
00096 
00097 #endif // vcsl_perspective_h_