2 #ifndef vgl_norm_trans_2d_hxx_ 3 #define vgl_norm_trans_2d_hxx_ 11 # include <vcl_msvc_warnings.h> 13 #include <vnl/vnl_math.h> 79 this->center_of_mass(points, cx, cy);
81 std::vector<vgl_homg_point_2d<T> > temp;
83 pit = points.begin(); pit != points.end(); pit++)
92 if (!this->scale_xyroot2(temp, radius))
97 T sdx = 1, sdy = 1, c = 1, s = 0;
98 if (!this->scale_aniostropic(temp, sdx, sdy, c, s))
100 T scx = 1/sdx, scy = 1/sdy;
101 T data[] = { c*scx, -s*scx, -c*scx*cx +s*scx*cy,
102 s*scy, c*scy, -s*scy*cx -c*scy*cy };
121 std::vector<vgl_homg_point_2d<T> > points;
123 lit != lines.end(); lit++)
129 return this->compute_from_points(points, isotropic);
143 std::vector<vgl_homg_point_2d<T> > points = pts;
145 lit != lines.end(); lit++)
151 return this->compute_from_points(points, isotropic);
164 T tol = static_cast<T>(1e-06);
165 unsigned n = in.size();
166 for (
unsigned i = 0; i < n; ++i)
168 if (in[i].ideal(tol))
198 for (
unsigned i = 0; i < in.size(); ++i)
200 if (in[i].ideal(tol))
203 magnitude += vnl_math::hypot(p.
x(),p.
y());
209 radius = T(magnitude / (numfinite*vnl_math::sqrt2));
223 T& sdx, T& sdy, T& c, T& s)
227 unsigned n = in.size();
229 double Sx2=0, Sxy=0, Sy2=0;
230 for (
unsigned i = 0; i < n; ++i)
232 if (in[i].ideal(tol))
248 t = 0.5*std::atan( -2.0*Sxy/(Sx2-Sy2) );
250 double dc = std::cos(t), ds = std::sin(t);
253 double sddx = std::sqrt( (dc*dc*Sx2-2.0*dc*ds*Sxy+ds*ds*Sy2)/count );
254 double sddy = std::sqrt( (ds*ds*Sx2+2.0*dc*ds*Sxy+dc*dc*Sy2)/count );
257 sdx = static_cast<T>(sddx);
258 sdy = static_cast<T>(sddy);
259 c = static_cast<T>(dc);
260 s = static_cast<T>(ds);
261 return sdx>tol && sdy >tol;
265 #undef VGL_NORM_TRANS_2D_INSTANTIATE 266 #define VGL_NORM_TRANS_2D_INSTANTIATE(T) \ 267 template class vgl_norm_trans_2d<T > 269 #endif // vgl_norm_trans_2d_hxx_
A class to hold a plane-to-plane projective transformation matrix and to perform common operations us...
a point in 2D nonhomogeneous space
Represents a homogeneous 2D line.
vgl_h_matrix_2d & set_affine(vnl_matrix_fixed< T, 2, 3 > const &M23)
set the transform to a general affine transform matrix.
static bool scale_aniostropic(std::vector< vgl_homg_point_2d< T > > const &in, T &sdx, T &sdy, T &c, T &s)
The similarity transform that normalizes a point set.
static void center_of_mass(std::vector< vgl_homg_point_2d< T > > const &points, T &cx, T &cy)
bool compute_from_lines(std::vector< vgl_homg_line_2d< T > > const &lines, bool isotropic=true)
The normalizing transform for lines is computed from the set of points defined by the intersection of...
bool compute_from_points_and_lines(std::vector< vgl_homg_point_2d< T > > const &pts, std::vector< vgl_homg_line_2d< T > > const &lines, bool isotropic=true)
The normalizing transform for points and lines is computed from the set of points used by compute_fro...
bool compute_from_points(std::vector< vgl_homg_point_2d< T > > const &points, bool isotropic=true)
compute the normalizing transform.
vgl_h_matrix_2d & set_translation(T tx, T ty)
set H[0][2] = tx and H[1][2] = ty, other elements unaltered.
vgl_h_matrix_2d & set_scale(T scale)
compose the current transform with a uniform scaling transformation, S.
Represents a homogeneous 2D point.
vgl_h_matrix_2d & set_identity()
initialize the transformation to identity.
static bool scale_xyroot2(std::vector< vgl_homg_point_2d< T > > const &in, T &radius)