vimt_transform_2d Class Reference

#include <vimt_transform_2d.h>

List of all members.


Detailed Description

2D transform, which can be up to a projective transformation.

In order of complexity the transform can be

   Identity     x->x, y->y
   Translation  x->x + tx, y->y + ty
   ZoomOnly     x->sx.x + tx, y->sy.y + ty
   RigidBody    (Translate + rotation)
   Euclidean    (Translation + rotation + scale)
   Affine
   Projective
   

NOTES: The transformation can be represented by a 3x3 matrix mapping homogeneous co-ordinates about.

   ( xx xy xt )
   ( yx yy yt )
   ( tx ty tt )
   
For efficiency the elements are stored explicitly, rather than in a vnl_matrix<double>, to avoid lots of copying of matrices with all the attendant memory allocation.

Example:

 vimt_transform_2d T1;
 vimt_transform_2d T2;
 T1.set_zoom(scale,translation.x(),translation.y());
 T2.set_similarity(scale2,theta,translation2.x(),translation2.y());

 vimt_transform_2d T3 = T2 * T1; // T1 followed by T2

 vgl_point_2d<double>  p(10,10);
 vgl_point_2d<double>  p_new = T3(p);

 vimt_transform_2d T_inverse = T3.inverse();

Definition at line 54 of file vimt_transform_2d.h.


Public Types

enum  Form {
  Identity, Translation, ZoomOnly, RigidBody,
  Similarity, Affine, Projective, Reflection
}
 Defines form of transformation. More...

Public Member Functions

 vimt_transform_2d ()
bool is_identity () const
Form form () const
vnl_matrix< double > matrix () const
void matrix (vnl_matrix< double > &) const
void params (vnl_vector< double > &v) const
 Fills v with parameters.
void set (const vnl_vector< double > &v, Form)
 Sets transform using v (converse of params(v)).
void set_identity ()
 Set to identity transformation.
void set_zoom_only (double s_x, double s_y, double t_x, double t_y)
 Sets the transformation to be separable affine.
void set_zoom_only (double s, double t_x, double t_y)
 Sets the transformation to be a zoom.
void set_translation (double t_x, double t_y)
 Sets the transformation to be a translation.
void set_rigid_body (double theta, double t_x, double t_y)
 Sets the transformation to rotation then translation.
void set_similarity (double s, double theta, double t_x, double t_y)
 Sets the transformation to apply scaling, rotation then translation.
void set_similarity (const vgl_point_2d< double > &dx, const vgl_point_2d< double > &t)
 Sets Euclidean transformation.
void set_similarity (const vgl_vector_2d< double > &dx, const vgl_point_2d< double > &t)
 Sets Euclidean transformation.
void set_reflection (const vgl_point_2d< double > &m1, const vgl_point_2d< double > &m2)
 reflect about a line though the points m1, and m2.
void set_affine (const vnl_matrix< double > &)
 Sets to be 2D affine transformation using 2x3 matrix.
void set_affine (const vgl_point_2d< double > &p, const vgl_vector_2d< double > &u, const vgl_vector_2d< double > &v)
 Sets to be 2D affine transformation T(x,y)=p+x.u+y.v.
void set_projective (const vnl_matrix< double > &)
 Sets to be 2D projective transformation.
vgl_point_2d< double > origin () const
 Returns the coordinates of the origin.
void set_origin (const vgl_point_2d< double > &)
 Modifies the transformation so that operator()(vgl_point_2d<double> (0,0)) == p.
vgl_point_2d< double > operator() (double x, double y) const
 Applies transformation to (x,y).
vgl_point_2d< double > operator() (const vgl_point_2d< double > &p) const
 Returns transformation applied to point p.
vimt_transform_2d inverse () const
 Calculates inverse of this transformation.
vgl_vector_2d< double > delta (const vgl_point_2d< double > &p, const vgl_vector_2d< double > &dp) const
 Returns change in transformed point when original point moved by dp.
short version_no () const
void print_summary (vcl_ostream &) const
void b_write (vsl_b_ostream &bfs) const
void b_read (vsl_b_istream &bfs)
bool operator== (const vimt_transform_2d &t) const
 True if t is the same as this.

Private Member Functions

void calcInverse () const
void setCheck (int n1, int n2, const char *str) const

Private Attributes

double xx_
double xy_
double xt_
double yx_
double yy_
double yt_
double tx_
double ty_
double tt_
Form form_
double xx2_
double xy2_
double xt2_
double yx2_
double yy2_
double yt2_
double tx2_
double ty2_
double tt2_
bool inv_uptodate_

Friends

vimt_transform_2d operator* (const vimt_transform_2d &, const vimt_transform_2d &)
 Transform composition (L*R)(x) = L(R(x)).

Member Enumeration Documentation

Defines form of transformation.

Enumerator:
Identity 
Translation 
ZoomOnly 
RigidBody 
Similarity 
Affine 
Projective 
Reflection 

Definition at line 58 of file vimt_transform_2d.h.


Constructor & Destructor Documentation

vimt_transform_2d::vimt_transform_2d (  )  [inline]

Definition at line 67 of file vimt_transform_2d.h.


Member Function Documentation

bool vimt_transform_2d::is_identity (  )  const [inline]

Definition at line 74 of file vimt_transform_2d.h.

Form vimt_transform_2d::form (  )  const [inline]

Definition at line 75 of file vimt_transform_2d.h.

vnl_matrix< double > vimt_transform_2d::matrix (  )  const

Definition at line 17 of file vimt_transform_2d.cxx.

void vimt_transform_2d::matrix ( vnl_matrix< double > &  M  )  const

Definition at line 24 of file vimt_transform_2d.cxx.

void vimt_transform_2d::params ( vnl_vector< double > &  v  )  const

Fills v with parameters.

Definition at line 33 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set ( const vnl_vector< double > &  v,
Form  form 
)

Sets transform using v (converse of params(v)).

Definition at line 94 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_identity (  ) 

Set to identity transformation.

Definition at line 154 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_zoom_only ( double  s_x,
double  s_y,
double  t_x,
double  t_y 
)

Sets the transformation to be separable affine.

x' = s_x.x + t_x, y' = s_y.y + t_y s_x: Scaling in x s_y: Scaling in y t_x: Translation in x t_y: Translation in y

Definition at line 194 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_zoom_only ( double  s,
double  t_x,
double  t_y 
) [inline]

Sets the transformation to be a zoom.

x' = s.x + t_x, y' = s.y + t_y s: Scaling t_x: Translation in x t_y: Translation in y

Definition at line 97 of file vimt_transform_2d.h.

void vimt_transform_2d::set_translation ( double  t_x,
double  t_y 
)

Sets the transformation to be a translation.

t_x: Translation in x t_y: Translation in y

Definition at line 166 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_rigid_body ( double  theta,
double  t_x,
double  t_y 
)

Sets the transformation to rotation then translation.

theta: rotation t_x: Translation in x t_y: Translation in y

Definition at line 238 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_similarity ( double  s,
double  theta,
double  t_x,
double  t_y 
)

Sets the transformation to apply scaling, rotation then translation.

s: Scaling theta: rotation t_x: Translation in x t_y: Translation in y

Definition at line 256 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_similarity ( const vgl_point_2d< double > &  dx,
const vgl_point_2d< double > &  t 
)

Sets Euclidean transformation.

Parameters:
dx Rotation and scaling of x axis
t Translation

Definition at line 275 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_similarity ( const vgl_vector_2d< double > &  dx,
const vgl_point_2d< double > &  t 
)

Sets Euclidean transformation.

Parameters:
dx Rotation and scaling of x axis
t Translation

Definition at line 287 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_reflection ( const vgl_point_2d< double > &  m1,
const vgl_point_2d< double > &  m2 
)

reflect about a line though the points m1, and m2.

Definition at line 206 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_affine ( const vnl_matrix< double > &  M23  ) 

Sets to be 2D affine transformation using 2x3 matrix.

Definition at line 299 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_affine ( const vgl_point_2d< double > &  p,
const vgl_vector_2d< double > &  u,
const vgl_vector_2d< double > &  v 
)

Sets to be 2D affine transformation T(x,y)=p+x.u+y.v.

Definition at line 326 of file vimt_transform_2d.cxx.

void vimt_transform_2d::set_projective ( const vnl_matrix< double > &  M33  ) 

Sets to be 2D projective transformation.

Definition at line 340 of file vimt_transform_2d.cxx.

vgl_point_2d<double> vimt_transform_2d::origin (  )  const [inline]

Returns the coordinates of the origin.

I.e. operator()(vgl_point_2d<double> (0,0))

Definition at line 142 of file vimt_transform_2d.h.

void vimt_transform_2d::set_origin ( const vgl_point_2d< double > &  p  ) 

Modifies the transformation so that operator()(vgl_point_2d<double> (0,0)) == p.

The rest of the transformation is unaffected. If the transformation was previously the identity, it becomes a translation.

Definition at line 184 of file vimt_transform_2d.cxx.

vgl_point_2d< double > vimt_transform_2d::operator() ( double  x,
double  y 
) const

Applies transformation to (x,y).

Definition at line 358 of file vimt_transform_2d.cxx.

vgl_point_2d<double> vimt_transform_2d::operator() ( const vgl_point_2d< double > &  p  )  const [inline]

Returns transformation applied to point p.

Definition at line 153 of file vimt_transform_2d.h.

vimt_transform_2d vimt_transform_2d::inverse (  )  const

Calculates inverse of this transformation.

Definition at line 411 of file vimt_transform_2d.cxx.

vgl_vector_2d< double > vimt_transform_2d::delta ( const vgl_point_2d< double > &  p,
const vgl_vector_2d< double > &  dp 
) const

Returns change in transformed point when original point moved by dp.

Point dp: Movement from point Returns: T(p+dp)-T(p)

Definition at line 386 of file vimt_transform_2d.cxx.

short vimt_transform_2d::version_no (  )  const

Definition at line 708 of file vimt_transform_2d.cxx.

void vimt_transform_2d::print_summary ( vcl_ostream &  o  )  const

Definition at line 640 of file vimt_transform_2d.cxx.

void vimt_transform_2d::b_write ( vsl_b_ostream bfs  )  const

Definition at line 711 of file vimt_transform_2d.cxx.

void vimt_transform_2d::b_read ( vsl_b_istream bfs  ) 

Definition at line 720 of file vimt_transform_2d.cxx.

bool vimt_transform_2d::operator== ( const vimt_transform_2d t  )  const

True if t is the same as this.

Definition at line 491 of file vimt_transform_2d.cxx.

void vimt_transform_2d::calcInverse (  )  const [private]

Definition at line 431 of file vimt_transform_2d.cxx.

void vimt_transform_2d::setCheck ( int  n1,
int  n2,
const char *  str 
) const [private]

Definition at line 86 of file vimt_transform_2d.cxx.


Friends And Related Function Documentation

vimt_transform_2d operator* ( const vimt_transform_2d L,
const vimt_transform_2d R 
) [friend]

Transform composition (L*R)(x) = L(R(x)).

Definition at line 506 of file vimt_transform_2d.cxx.


Member Data Documentation

double vimt_transform_2d::xx_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::xy_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::xt_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::yx_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::yy_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::yt_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::tx_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::ty_ [private]

Definition at line 175 of file vimt_transform_2d.h.

double vimt_transform_2d::tt_ [private]

Definition at line 175 of file vimt_transform_2d.h.

Definition at line 176 of file vimt_transform_2d.h.

double vimt_transform_2d::xx2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::xy2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::xt2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::yx2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::yy2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::yt2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::tx2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::ty2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

double vimt_transform_2d::tt2_ [mutable, private]

Definition at line 179 of file vimt_transform_2d.h.

bool vimt_transform_2d::inv_uptodate_ [mutable, private]

Definition at line 180 of file vimt_transform_2d.h.


The documentation for this class was generated from the following files:

Generated on Sun Nov 22 06:24:36 2009 for contrib/mul/vimt by  doxygen 1.5.5