Go to the documentation of this file.00001
00002 #ifndef vpgl_poly_radial_distortion_h_
00003 #define vpgl_poly_radial_distortion_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "vpgl_radial_distortion.h"
00016 #include <vgl/vgl_point_2d.h>
00017 #include <vcl_vector.h>
00018 #include <vcl_cassert.h>
00019
00020
00021 template <class T, int n>
00022 class vpgl_poly_radial_distortion : public vpgl_radial_distortion<T>
00023 {
00024 public:
00025
00026 vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center, const T* k)
00027 : vpgl_radial_distortion<T>(center,true)
00028 {
00029 set_coefficients(k);
00030 }
00031
00032
00033 vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
00034 const vgl_point_2d<T>& distorted_center,
00035 const T* k)
00036 : vpgl_radial_distortion<T>(center,distorted_center,true)
00037 {
00038 set_coefficients(k);
00039 }
00040
00041
00042 vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
00043 const vcl_vector<T>& k)
00044 : vpgl_radial_distortion<T>(center)
00045 {
00046 set_coefficients(k);
00047 }
00048
00049
00050 vpgl_poly_radial_distortion<T,n>(const vgl_point_2d<T>& center,
00051 const vgl_point_2d<T>& distorted_center,
00052 const vcl_vector<T>& k)
00053 : vpgl_radial_distortion<T>(center, distorted_center)
00054 {
00055 set_coefficients(k);
00056 }
00057
00058 void set_coefficients(const vcl_vector<T>& k)
00059 {
00060 assert(k.size() == n);
00061 T* coptr = coefficients_;
00062 for (unsigned int i=0; i<n; ++i, ++coptr)
00063 *coptr = k[i];
00064 }
00065
00066 void set_coefficients(const T* k)
00067 {
00068 const T* kptr = k;
00069 T* coptr = coefficients_;
00070 for (unsigned int i=0; i<n; ++i, ++kptr, ++coptr)
00071 *coptr = *kptr;
00072 };
00073
00074
00075 virtual T distort_radius( T radius ) const;
00076
00077
00078 virtual T distort_radius_deriv( T radius ) const;
00079
00080 protected:
00081
00082 T coefficients_[n];
00083 };
00084
00085
00086 #endif // vpgl_poly_radial_distortion_h_