00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008 #include "vimt_transform_2d.h"
00009 #include <vcl_cmath.h>
00010 #include <vcl_cstdlib.h>
00011 #include <vcl_cassert.h>
00012 #include <vsl/vsl_indent.h>
00013 #include <vnl/vnl_vector.h>
00014 #include <vnl/vnl_matrix.h>
00015 #include <vnl/vnl_inverse.h>
00016
00017 vnl_matrix<double> vimt_transform_2d::matrix() const
00018 {
00019 vnl_matrix<double> M(3,3);
00020 matrix(M);
00021 return M;
00022 }
00023
00024 void vimt_transform_2d::matrix(vnl_matrix<double>& M) const
00025 {
00026 M.set_size(3,3);
00027 double**m_data = M.data_array();
00028 m_data[0][0]=xx_; m_data[0][1]=xy_; m_data[0][2]=xt_;
00029 m_data[1][0]=yx_; m_data[1][1]=yy_; m_data[1][2]=yt_;
00030 m_data[2][0]=tx_; m_data[2][1]=ty_; m_data[2][2]=tt_;
00031 }
00032
00033 void vimt_transform_2d::params(vnl_vector<double>& v) const
00034 {
00035 double *v_data;
00036 switch (form_)
00037 {
00038 case (Identity):
00039 v.set_size(0);
00040 break;
00041 case (Translation):
00042 v.set_size(2);
00043 v(0)=xt_; v(1)=yt_;
00044 break;
00045 case (ZoomOnly):
00046 v.set_size(4);
00047 v(0)=xx_; v(1)=yy_;
00048 v(2)=xt_; v(3)=yt_;
00049 break;
00050 case (RigidBody):
00051 v.set_size(3);
00052 v(0)=vcl_atan2(-xy_,xx_);
00053 v(1)=xt_; v(2)=yt_;
00054 break;
00055 case (Reflection):
00056 v.set_size(4);
00057 v_data = v.begin();
00058 v_data[0]=xx_; v_data[1]=xy_;
00059 v_data[2]=xt_; v_data[3]=yt_;
00060 break;
00061 case (Similarity):
00062 v.set_size(4);
00063 v_data = v.begin();
00064 v_data[0]=xx_; v_data[1]=xy_;
00065 v_data[2]=xt_; v_data[3]=yt_;
00066 break;
00067 case (Affine):
00068 v.set_size(6);
00069 v_data = v.begin();
00070 v_data[0]=xx_; v_data[1]=xy_; v_data[2]=xt_;
00071 v_data[3]=yx_; v_data[4]=yy_; v_data[5]=yt_;
00072 break;
00073 case (Projective):
00074 v.set_size(9);
00075 v_data = v.begin();
00076 v_data[0]=xx_; v_data[1]=xy_; v_data[2]=xt_;
00077 v_data[3]=yx_; v_data[4]=yy_; v_data[5]=yt_;
00078 v_data[6]=tx_; v_data[7]=ty_; v_data[8]=tt_;
00079 break;
00080 default:
00081 vcl_cerr<<"vimt_transform_2d::params() Unexpected form: "<<int(form_)<<vcl_endl;
00082 vcl_abort();
00083 }
00084 }
00085
00086 void vimt_transform_2d::setCheck(int n1,int n2,const char* str) const
00087 {
00088 if (n1==n2) return;
00089 vcl_cerr<<"vimt_transform_2d::set() "<<n1<<" parameters required for "
00090 <<str<<". Passed "<<n2<<vcl_endl;
00091 vcl_abort();
00092 }
00093
00094 void vimt_transform_2d::set(const vnl_vector<double>& v, Form form)
00095 {
00096 int n=v.size();
00097 const double* v_data = v.begin();
00098
00099 switch (form)
00100 {
00101 case (Identity):
00102 set_identity();
00103 break;
00104 case (Translation):
00105 setCheck(2,n,"Translation");
00106 set_translation(v_data[0],v_data[1]);
00107 break;
00108 case (ZoomOnly):
00109 setCheck(4,n,"ZoomOnly");
00110 set_zoom_only(v_data[0],v_data[1],v_data[2],v_data[3]);
00111 break;
00112 case (RigidBody):
00113 setCheck(3,n,"RigidBody");
00114 set_rigid_body(v_data[0],v_data[1],v_data[2]);
00115 break;
00116 case (Reflection):
00117 setCheck(4,n,"Reflection");
00118 xx_ = v_data[0]; xy_ = v_data[1];
00119 yx_ = xy_; yy_ = -xx_;
00120 xt_ = v_data[2]; yt_ = v_data[3];
00121 form_ = Reflection;
00122 inv_uptodate_=false;
00123 break;
00124 case (Similarity):
00125 setCheck(4,n,"Similarity");
00126 xx_ = v_data[0]; xy_ = v_data[1];
00127 yx_ = -xy_; yy_=xx_;
00128 xt_ = v_data[2]; yt_ = v_data[3];
00129 form_ = Similarity;
00130 inv_uptodate_=false;
00131 break;
00132 case (Affine):
00133 setCheck(6,n,"Affine");
00134 xx_ = v_data[0]; xy_ = v_data[1]; xt_ = v_data[2];
00135 yx_ = v_data[3]; yy_ = v_data[4]; yt_ = v_data[5];
00136 form_ = Affine;
00137 inv_uptodate_=false;
00138 break;
00139 case (Projective):
00140 setCheck(9,n,"Projective");
00141 xx_ = v_data[0]; xy_ = v_data[1]; xt_ = v_data[2];
00142 yx_ = v_data[3]; yy_ = v_data[4]; yt_ = v_data[5];
00143 tx_ = v_data[6]; ty_ = v_data[7]; tt_ = v_data[8];
00144 form_ = Projective;
00145 inv_uptodate_=false;
00146 break;
00147 default:
00148 vcl_cerr<<"vimt_transform_2d::set() Unexpected form: "<<int(form)<<vcl_endl;
00149 vcl_abort();
00150 }
00151 }
00152
00153
00154 void vimt_transform_2d::set_identity()
00155 {
00156 if (form_==Identity) return;
00157 form_=Identity;
00158 xx_=yy_=tt_=1.0;
00159 xy_=xt_=0.0;
00160 yx_=yt_=0.0;
00161 tx_=ty_=0.0;
00162
00163 inv_uptodate_=false;
00164 }
00165
00166 void vimt_transform_2d::set_translation(double t_x, double t_y)
00167 {
00168 if (t_x==0 && t_y==0)
00169 set_identity();
00170 else
00171 {
00172 form_=Translation;
00173 xx_=yy_=tt_=1.0;
00174 xy_=0.0;
00175 yx_=0.0;
00176 tx_=ty_=0.0;
00177 xt_=t_x;
00178 yt_=t_y;
00179 }
00180
00181 inv_uptodate_=false;
00182 }
00183
00184 void vimt_transform_2d::set_origin( const vgl_point_2d<double> & p )
00185 {
00186 xt_ = p.x()*tt_;
00187 yt_ = p.y()*tt_;
00188
00189 if (form_ == Identity) form_=Translation;
00190
00191 inv_uptodate_=false;
00192 }
00193
00194 void vimt_transform_2d::set_zoom_only(double s_x, double s_y, double t_x, double t_y)
00195 {
00196 form_=ZoomOnly;
00197 xx_=s_x; yy_=s_y; tt_=1.0;
00198 xt_=t_x; yt_=t_y;
00199 xy_=yx_=tx_=ty_=0.0;
00200
00201 inv_uptodate_=false;
00202 }
00203
00204
00205
00206 void vimt_transform_2d::set_reflection( const vgl_point_2d<double> & m1, const vgl_point_2d<double> & m2)
00207 {
00208 form_=Reflection;
00209
00210 assert (m1 != m2);
00211 const double m1x = m1.x();
00212 const double m1y = m1.y();
00213 const double m2x = m2.x();
00214 const double m2y = m2.y();
00215 const double dx = m2x - m1x;
00216 const double dy = m2y - m1y;
00217 const double dx2dy2 = dx*dx + dy*dy;
00218
00219
00220
00221
00222 xx_ = (dx*dx - dy*dy) / dx2dy2;
00223
00224 xy_ = 2.0*dx*dy / dx2dy2;
00225
00226 xt_ = (2.0*m1x*dy*dy - 2.0*m1y*dx*dy) / dx2dy2;
00227
00228 yx_ = 2.0*dx*dy / dx2dy2;
00229
00230 yy_ = (dy*dy - dx*dx) / dx2dy2;
00231
00232 yt_ = (2.0*m1y*dx*dx - 2.0*m1x*dx*dy) / dx2dy2;
00233
00234 tx_ = ty_ = 0.0;
00235 tt_ = 1.0;
00236 }
00237
00238 void vimt_transform_2d::set_rigid_body(double theta, double t_x, double t_y)
00239 {
00240 if (theta==0.0)
00241 set_translation(t_x,t_y);
00242 else
00243 {
00244 form_=RigidBody;
00245 double a=vcl_cos(theta);
00246 double b=vcl_sin(theta);
00247 xx_=a; xy_=-b;
00248 yx_=b; yy_=a;
00249 xt_=t_x; yt_=t_y;
00250 tx_=ty_=0.0; tt_=1.0;
00251 }
00252
00253 inv_uptodate_=false;
00254 }
00255
00256 void vimt_transform_2d::set_similarity(double s, double theta, double t_x, double t_y)
00257 {
00258 if (s==1.0)
00259 set_rigid_body(theta,t_x,t_y);
00260 else
00261 {
00262 form_=Similarity;
00263 double a=s*vcl_cos(theta);
00264 double b=s*vcl_sin(theta);
00265 xx_=a; xy_=-b;
00266 yx_=b; yy_=a;
00267 xt_=t_x; yt_=t_y;
00268 tx_=ty_=0.0; tt_=1.0;
00269 }
00270
00271 inv_uptodate_=false;
00272 }
00273
00274
00275 void vimt_transform_2d::set_similarity(const vgl_point_2d<double> & dx, const vgl_point_2d<double> & t)
00276 {
00277 form_=Similarity;
00278 xx_ = dx.x(); xy_ = -dx.y();
00279 yx_ = dx.y(); yy_ = dx.x();
00280 xt_ = t.x(); yt_ = t.y();
00281 tx_=ty_=0.0; tt_=1.0;
00282 inv_uptodate_=false;
00283 }
00284
00285
00286 void vimt_transform_2d::set_affine(const vnl_matrix<double>& M23)
00287 {
00288 if ((M23.rows()!=2) || (M23.columns()!=3))
00289 {
00290 vcl_cerr<<"vimt_transform_2d::affine : Expect 2x3 matrix, got "<<M23.rows()<<" x "<<M23.columns()<<vcl_endl;
00291 vcl_abort();
00292 }
00293
00294 const double *const *m_data=M23.data_array();
00295
00296 if (m_data[0][0]*m_data[1][1] < m_data[0][1]*m_data[1][0])
00297 {
00298 vcl_cerr << "vimt_transform_2d::affine :\n"
00299 << "sub (2x2) matrix should have positive determinant\n";
00300 vcl_abort();
00301 }
00302
00303 xx_=m_data[0][0]; xy_=m_data[0][1]; xt_=m_data[0][2];
00304 yx_=m_data[1][0]; yy_=m_data[1][1]; yt_=m_data[1][2];
00305 tx_=ty_=0.0; tt_=1.0;
00306
00307 form_=Affine;
00308
00309 inv_uptodate_=false;
00310 }
00311
00312
00313 void vimt_transform_2d::set_affine(const vgl_point_2d<double> & p,
00314 const vgl_vector_2d<double> & u,
00315 const vgl_vector_2d<double> & v)
00316 {
00317 xt_ = p.x();
00318 yt_ = p.y();
00319 xx_ = u.x();
00320 yx_ = u.y();
00321 xy_ = v.x();
00322 yy_ = v.y();
00323 form_=Affine;
00324 inv_uptodate_=false;
00325 }
00326
00327 void vimt_transform_2d::set_projective(const vnl_matrix<double>& M33)
00328 {
00329 if ((M33.rows()!=3) || (M33.columns()!=3))
00330 {
00331 vcl_cerr<<"vimt_transform_2d::projective : Expect 3x3 matrix, got "<<M33.rows()<<" x "<<M33.columns()<<vcl_endl;
00332 vcl_abort();
00333 }
00334
00335 const double *const *m_data=M33.data_array();
00336 xx_=m_data[0][0]; xy_=m_data[0][1]; xt_=m_data[0][2];
00337 yx_=m_data[1][0]; yy_=m_data[1][1]; yt_=m_data[1][2];
00338 tx_=m_data[2][0]; ty_=m_data[2][1]; tt_=m_data[2][2];
00339
00340 form_=Projective;
00341
00342 inv_uptodate_=false;
00343 }
00344
00345 vgl_point_2d<double> vimt_transform_2d::operator()(double x, double y) const
00346 {
00347 double z;
00348 switch (form_)
00349 {
00350 case Identity :
00351 return vgl_point_2d<double> (x,y);
00352 case Translation :
00353 return vgl_point_2d<double> (x+xt_,y+yt_);
00354 case ZoomOnly :
00355 return vgl_point_2d<double> (x*xx_+xt_,y*yy_+yt_);
00356 case RigidBody :
00357 case Similarity :
00358 case Reflection :
00359 case Affine :
00360 return vgl_point_2d<double> (x*xx_+y*xy_+xt_,x*yx_+y*yy_+yt_);
00361 case Projective :
00362 z=x*tx_+y*ty_+tt_;
00363 if (z==0) return vgl_point_2d<double> (0,0);
00364 else return vgl_point_2d<double> ((x*xx_+y*xy_+xt_)/z,(x*yx_+y*yy_+yt_)/z);
00365 default:
00366 vcl_cerr<<"vimt_transform_2d::operator() : Unrecognised form:"<<int(form_)<<vcl_endl;
00367 vcl_abort();
00368 }
00369
00370 return vgl_point_2d<double> ();
00371 }
00372
00373 vgl_vector_2d<double> vimt_transform_2d::delta(const vgl_point_2d<double>& p, const vgl_vector_2d<double>& dp) const
00374 {
00375 switch (form_)
00376 {
00377 case Identity :
00378 case Translation:
00379 return dp;
00380 case ZoomOnly :
00381 return vgl_vector_2d<double> (dp.x()*xx_,dp.y()*yy_);
00382 case RigidBody :
00383 case Similarity :
00384 case Reflection :
00385 case Affine :
00386 return vgl_vector_2d<double> (dp.x()*xx_+dp.y()*xy_,dp.x()*yx_+dp.y()*yy_);
00387 case Projective :
00388 return operator()(p+dp)-operator()(p);
00389 default:
00390 vcl_cerr<<"vimt_transform_2d::delta() : Unrecognised form:"<<int(form_)<<vcl_endl;
00391 vcl_abort();
00392 }
00393
00394 return vgl_vector_2d<double> ();
00395 }
00396
00397
00398 vimt_transform_2d vimt_transform_2d::inverse() const
00399 {
00400 if (!inv_uptodate_) calcInverse();
00401
00402 vimt_transform_2d inv;
00403
00404 inv.xx_ = xx2_; inv.xy_ = xy2_; inv.xt_ = xt2_;
00405 inv.yx_ = yx2_; inv.yy_ = yy2_; inv.yt_ = yt2_;
00406 inv.tx_ = tx2_; inv.ty_ = ty2_; inv.tt_ = tt2_;
00407
00408 inv.xx2_ = xx_; inv.xy2_ = xy_; inv.xt2_ = xt_;
00409 inv.yx2_ = yx_; inv.yy2_ = yy_; inv.yt2_ = yt_;
00410 inv.tx2_ = tx_; inv.ty2_ = ty_; inv.tt2_ = tt_;
00411
00412 inv.form_ = form_;
00413 inv.inv_uptodate_ = 1;
00414
00415 return inv;
00416 }
00417
00418 void vimt_transform_2d::calcInverse() const
00419 {
00420 xx2_ = yy2_ = tt2_ = 1;
00421 xy2_ = xt2_ = yx2_ = yt2_ = tx2_ = ty2_ = 0;
00422
00423 switch (form_)
00424 {
00425 case Identity :
00426 break;
00427 case Translation :
00428 xt2_ = -xt_;
00429 yt2_ = -yt_;
00430 break;
00431 case ZoomOnly :
00432 assert(xx_ != 0 && yy_ != 0);
00433 xx2_=1.0/xx_;
00434 xt2_=-xt_/xx_;
00435 yy2_=1.0/yy_;
00436 yt2_=-yt_/yy_;
00437 break;
00438 case RigidBody :
00439 xx2_ = xx_; xy2_ = yx_;
00440 yx2_ = xy_; yy2_ = yy_;
00441 xt2_ = -(xx2_*xt_ + xy2_*yt_);
00442 yt2_ = -(yx2_*xt_ + yy2_*yt_);
00443 break;
00444 case Similarity :
00445 case Affine :
00446 {
00447 double det = xx_*yy_-xy_*yx_;
00448 if (det==0)
00449 {
00450 vcl_cerr<<"vimt_transform_2d::calcInverse() : No inverse exists for this affine transform (det==0)\n";
00451 vcl_abort();
00452 }
00453 xx2_=yy_/det; xy2_=-xy_/det;
00454 yx2_=-yx_/det; yy2_=xx_/det;
00455 xt2_=-xx2_*xt_-xy2_*yt_;
00456 yt2_=-yx2_*xt_-yy2_*yt_;
00457 break;
00458 }
00459 case Projective :
00460 {
00461 vnl_matrix<double> M(3,3),M_inv(3,3);
00462 matrix(M);
00463 M_inv = vnl_inverse(M);
00464 double **m_data=M_inv.data_array();
00465 xx2_=m_data[0][0]; xy2_=m_data[0][1]; xt2_=m_data[0][2];
00466 yx2_=m_data[1][0]; yy2_=m_data[1][1]; yt2_=m_data[1][2];
00467 tx2_=m_data[2][0]; ty2_=m_data[2][1]; tt2_=m_data[2][2];
00468 break;
00469 }
00470 default:
00471 vcl_cerr<<"vimt_transform_2d::calcInverse() : Unrecognised form:"<<int(form_)<<vcl_endl;
00472 vcl_abort();
00473 }
00474
00475 inv_uptodate_=true;
00476 }
00477
00478 bool vimt_transform_2d::operator==(const vimt_transform_2d& t) const
00479 {
00480 return
00481 xx_ == t.xx_ &&
00482 xy_ == t.xy_ &&
00483 xt_ == t.xt_ &&
00484 yx_ == t.yx_ &&
00485 yy_ == t.yy_ &&
00486 yt_ == t.yt_ &&
00487 tx_ == t.tx_ &&
00488 ty_ == t.ty_ &&
00489 tt_ == t.tt_;
00490 }
00491
00492 vimt_transform_2d operator*(const vimt_transform_2d& L, const vimt_transform_2d& R)
00493 {
00494
00495 vimt_transform_2d T;
00496
00497 if (L.form() == vimt_transform_2d::Identity)
00498 return R;
00499 else
00500 if (R.form() == vimt_transform_2d::Identity)
00501 return L;
00502 else
00503 if (L.form() == vimt_transform_2d::Translation)
00504 {
00505 T = R;
00506
00507 if (R.form() == vimt_transform_2d::Projective)
00508 {
00509 T.xx_ += L.xt_*R.tx_;
00510 T.xy_ += L.xt_*R.ty_;
00511 T.xt_ += L.xt_*R.tt_;
00512
00513 T.yx_ += L.yt_*R.tx_;
00514 T.yy_ += L.yt_*R.ty_;
00515 T.yt_ += L.yt_*R.tt_;
00516 }
00517 else
00518 {
00519 T.xt_ += L.xt_;
00520 T.yt_ += L.yt_;
00521 }
00522 }
00523 else
00524 if (R.form() == vimt_transform_2d::Translation)
00525 {
00526 T = L;
00527
00528 T.xt_ += L.xx_*R.xt_ +
00529 L.xy_*R.yt_;
00530 T.yt_ += L.yx_*R.xt_ +
00531 L.yy_*R.yt_;
00532 T.tt_ += L.tx_*R.xt_ +
00533 L.ty_*R.yt_;
00534 }
00535 else
00536 {
00537 if (R.form() == vimt_transform_2d::Projective ||
00538 L.form() == vimt_transform_2d::Projective)
00539 {
00540
00541 T.xx_ = L.xx_*R.xx_ + L.xy_*R.yx_ + L.xt_*R.tx_;
00542 T.xy_ = L.xx_*R.xy_ + L.xy_*R.yy_ + L.xt_*R.ty_;
00543 T.xt_ = L.xx_*R.xt_ + L.xy_*R.yt_ + L.xt_*R.tt_;
00544 T.yx_ = L.yx_*R.xx_ + L.yy_*R.yx_ + L.yt_*R.tx_;
00545 T.yy_ = L.yx_*R.xy_ + L.yy_*R.yy_ + L.yt_*R.ty_;
00546 T.yt_ = L.yx_*R.xt_ + L.yy_*R.yt_ + L.yt_*R.tt_;
00547 T.tx_ = L.tx_*R.xx_ + L.ty_*R.yx_ + L.tt_*R.tx_;
00548 T.ty_ = L.tx_*R.xy_ + L.ty_*R.yy_ + L.tt_*R.ty_;
00549 T.tt_ = L.tx_*R.xt_ + L.ty_*R.yt_ + L.tt_*R.tt_;
00550 }
00551 else
00552 {
00553
00554
00555 T.xx_ = L.xx_*R.xx_ + L.xy_*R.yx_;
00556 T.xy_ = L.xx_*R.xy_ + L.xy_*R.yy_;
00557 T.xt_ = L.xx_*R.xt_ + L.xy_*R.yt_ + L.xt_;
00558 T.yx_ = L.yx_*R.xx_ + L.yy_*R.yx_;
00559 T.yy_ = L.yx_*R.xy_ + L.yy_*R.yy_;
00560 T.yt_ = L.yx_*R.xt_ + L.yy_*R.yt_ + L.yt_;
00561 }
00562
00563
00564 if (R.form() == L.form())
00565 T.form_ = R.form();
00566 else
00567 {
00568 if (R.form() == vimt_transform_2d::Projective ||
00569 L.form() == vimt_transform_2d::Projective)
00570 T.form_ = vimt_transform_2d::Projective;
00571 else
00572 if (R.form() == vimt_transform_2d::Affine ||
00573 L.form() == vimt_transform_2d::Affine)
00574 T.form_ = vimt_transform_2d::Affine;
00575 else
00576 if (R.form() == vimt_transform_2d::Reflection ||
00577 L.form() == vimt_transform_2d::Reflection)
00578 T.form_ = vimt_transform_2d::Affine;
00579 else
00580 if (R.form() == vimt_transform_2d::Similarity ||
00581 L.form() == vimt_transform_2d::Similarity)
00582 T.form_ = vimt_transform_2d::Similarity;
00583 else
00584 if (R.form() == vimt_transform_2d::RigidBody ||
00585 L.form() == vimt_transform_2d::RigidBody)
00586 {
00587 if (R.form() == vimt_transform_2d::ZoomOnly)
00588 if (R.xx_ == R.yy_)
00589 T.form_ = vimt_transform_2d::Similarity;
00590 else
00591 T.form_ = vimt_transform_2d::Affine;
00592 else
00593 if (L.form() == vimt_transform_2d::ZoomOnly)
00594 if (L.xx_ == L.yy_)
00595 T.form_ = vimt_transform_2d::Similarity;
00596 else
00597 T.form_ = vimt_transform_2d::Affine;
00598 else
00599 T.form_ = vimt_transform_2d::RigidBody;
00600 }
00601 else
00602 if (R.form() == vimt_transform_2d::ZoomOnly ||
00603 L.form() == vimt_transform_2d::ZoomOnly)
00604 T.form_ = vimt_transform_2d::ZoomOnly;
00605 else
00606 T.form_ = vimt_transform_2d::Translation;
00607 }
00608
00609
00610
00611 if (T.form_ == vimt_transform_2d::RigidBody)
00612 {
00613 double det = T.xx_*T.yy_ - T.xy_*T.yx_;
00614 T.xx_ /= det;
00615 T.xy_ /= det;
00616 T.yx_ /= det;
00617 T.yy_ /= det;
00618 }
00619 }
00620
00621 T.inv_uptodate_ = false;
00622
00623 return T;
00624 }
00625
00626 void vimt_transform_2d::print_summary(vcl_ostream& o) const
00627 {
00628 o << vsl_indent()<< "Form: ";
00629 vsl_indent_inc(o);
00630 switch (form_)
00631 {
00632 case Identity:
00633 o << "Identity";
00634 break;
00635
00636 case Translation:
00637 o << "Translation (" << xt_ << ',' << yt_ << ')';
00638 break;
00639
00640 case ZoomOnly:
00641 o << "ZoomOnly\n"
00642 << vsl_indent()<< "scale factor = (" << xx_ << ',' << yy_ << ")\n"
00643 << vsl_indent()<< "translation = (" << xt_ << ',' << yt_ << ')';
00644 break;
00645
00646 case RigidBody:
00647 o << "RigidBody\n"
00648 << vsl_indent()<< "angle = " << vcl_atan2(yx_,xx_) << '\n'
00649 << vsl_indent()<< "translation = (" << xt_ << ',' << yt_ << ')';
00650 break;
00651
00652 case Similarity:
00653 o << "Similarity {"
00654 << " s= " << vcl_sqrt(xx_*xx_+xy_*xy_)
00655 << " A= " << vcl_atan2(xy_,xx_)
00656 << " t= (" << xt_ << ',' << yt_ << " ) }";
00657 break;
00658
00659 case Reflection:
00660 o << "Reflection\n"
00661 << vsl_indent()<< xx_ << ' ' << xy_ << '\n'
00662 << vsl_indent()<< yx_ << ' ' << yy_ << '\n'
00663 << vsl_indent()<< "translation = (" << xt_ << ',' << yt_ << ')';
00664 break;
00665
00666 case Affine:
00667 o << "Affine\n"
00668 << vsl_indent()<< xx_ << ' ' << xy_ << '\n'
00669 << vsl_indent()<< yx_ << ' ' << yy_ << '\n'
00670 << vsl_indent()<< "translation = (" << xt_ << ',' << yt_ << ')';
00671 break;
00672
00673 case Projective:
00674 o << "Projective\n"
00675 << vsl_indent()<< xx_ << ' ' << xy_ << ' ' << xt_ << '\n'
00676 << vsl_indent()<< yx_ << ' ' << yy_ << ' ' << yt_ << '\n'
00677 << vsl_indent()<< tx_ << ' ' << ty_ << ' ' << tt_;
00678 break;
00679 }
00680 vsl_indent_dec(o);
00681 }
00682
00683 vcl_ostream& operator<<( vcl_ostream& os, const vimt_transform_2d& t )
00684 {
00685 os << "vimt_transform_2d:\n";
00686 vsl_indent_inc(os);
00687 t.print_summary(os);
00688 vsl_indent_dec(os);
00689 return os;
00690 }
00691
00692 short