2D transform, which can be up to a projective transformation. More...
#include <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 |
vimt_transform_2d & | set_matrix (const vnl_matrix< double > &M) |
Define the transform in terms of a 3x3 homogeneous matrix. | |
void | params (vnl_vector< double > &v) const |
Fills v with parameters. | |
void | params_of (vnl_vector< double > &v, Form) const |
Fills v with parameters of transform of type Form. | |
vimt_transform_2d & | set (const vnl_vector< double > &v, Form) |
Sets transform using v (converse of params(v)). | |
vimt_transform_2d & | set_identity () |
Set to identity transformation. | |
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. | |
vimt_transform_2d & | set_zoom_only (double s, double t_x, double t_y) |
Sets the transformation to be a zoom. | |
vimt_transform_2d & | set_zoom_only (double s_x, double s_y) |
Sets the transformation to be separable affine. | |
vimt_transform_2d & | set_zoom_only (double s) |
Sets the transformation to be a zoom. | |
vimt_transform_2d & | set_translation (double t_x, double t_y) |
Sets the transformation to be a translation. | |
vimt_transform_2d & | set_rigid_body (double theta, double t_x, double t_y) |
Sets the transformation to rotation then translation. | |
vimt_transform_2d & | set_similarity (double s, double theta, double t_x, double t_y) |
Sets the transformation to apply scaling, rotation then translation. | |
vimt_transform_2d & | set_similarity (const vgl_point_2d< double > &dx, const vgl_point_2d< double > &t) |
Sets Euclidean transformation. | |
vimt_transform_2d & | set_similarity (const vgl_vector_2d< double > &dx, const vgl_point_2d< double > &t) |
Sets Euclidean transformation. | |
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. | |
vimt_transform_2d & | set_affine (const vnl_matrix< double > &) |
Sets to be 2D affine transformation using 2x3 matrix. | |
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. | |
vimt_transform_2d & | set_projective (const vnl_matrix< double > &) |
Sets to be 2D projective transformation. | |
vgl_point_2d< double > | origin () const |
Returns the coordinates of the origin. | |
vimt_transform_2d & | 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. | |
vimt_transform_2d & | simplify (double tol=1e-10) |
Reduce to the simplest form possible. | |
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)). |
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 59 of file vimt_transform_2d.h.
Defines form of transformation.
Definition at line 63 of file vimt_transform_2d.h.
vimt_transform_2d::vimt_transform_2d | ( | ) | [inline] |
Definition at line 72 of file vimt_transform_2d.h.
void vimt_transform_2d::b_read | ( | vsl_b_istream & | bfs | ) |
Definition at line 806 of file vimt_transform_2d.cxx.
void vimt_transform_2d::b_write | ( | vsl_b_ostream & | bfs | ) | const |
Definition at line 797 of file vimt_transform_2d.cxx.
void vimt_transform_2d::calcInverse | ( | ) | const [private] |
Definition at line 518 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 473 of file vimt_transform_2d.cxx.
Form vimt_transform_2d::form | ( | ) | const [inline] |
Definition at line 80 of file vimt_transform_2d.h.
vimt_transform_2d vimt_transform_2d::inverse | ( | ) | const |
Calculates inverse of this transformation.
Definition at line 498 of file vimt_transform_2d.cxx.
bool vimt_transform_2d::is_identity | ( | ) | const [inline] |
Definition at line 79 of file vimt_transform_2d.h.
vnl_matrix< double > vimt_transform_2d::matrix | ( | ) | const |
Definition at line 19 of file vimt_transform_2d.cxx.
void vimt_transform_2d::matrix | ( | vnl_matrix< double > & | M | ) | const |
Definition at line 26 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 445 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 172 of file vimt_transform_2d.h.
bool vimt_transform_2d::operator== | ( | const vimt_transform_2d & | t | ) | const |
True if t is the same as this.
Definition at line 578 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 161 of file vimt_transform_2d.h.
void vimt_transform_2d::params | ( | vnl_vector< double > & | v | ) | const [inline] |
Fills v with parameters.
Definition at line 91 of file vimt_transform_2d.h.
void vimt_transform_2d::params_of | ( | vnl_vector< double > & | v, |
Form | form | ||
) | const |
Fills v with parameters of transform of type Form.
Definition at line 54 of file vimt_transform_2d.cxx.
void vimt_transform_2d::print_summary | ( | vcl_ostream & | o | ) | const |
Definition at line 726 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set | ( | const vnl_vector< double > & | v, |
Form | form | ||
) |
Sets transform using v (converse of params(v)).
Definition at line 189 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_affine | ( | const vnl_matrix< double > & | M23 | ) |
Sets to be 2D affine transformation using 2x3 matrix.
Definition at line 387 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 413 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_identity | ( | ) |
Set to identity transformation.
Definition at line 246 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_matrix | ( | const vnl_matrix< double > & | M | ) |
Define the transform in terms of a 3x3 homogeneous matrix.
M | 3x3 homogeneous matrix defining the transform. |
Definition at line 37 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 274 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_projective | ( | const vnl_matrix< double > & | M33 | ) |
Sets to be 2D projective transformation.
Definition at line 428 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 294 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 328 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 345 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_similarity | ( | const vgl_point_2d< double > & | dx, |
const vgl_point_2d< double > & | t | ||
) |
Sets Euclidean transformation.
dx | Rotation and scaling of x axis |
t | Translation |
Definition at line 363 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::set_similarity | ( | const vgl_vector_2d< double > & | dx, |
const vgl_point_2d< double > & | t | ||
) |
Sets Euclidean transformation.
dx | Rotation and scaling of x axis |
t | Translation |
Definition at line 375 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 256 of file vimt_transform_2d.cxx.
vimt_transform_2d & 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 283 of file vimt_transform_2d.cxx.
vimt_transform_2d& 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 110 of file vimt_transform_2d.h.
vimt_transform_2d& vimt_transform_2d::set_zoom_only | ( | double | s_x, |
double | s_y | ||
) | [inline] |
Sets the transformation to be separable affine.
x' = s_x.x + xt_, y' = s_y.y + yt_ s_x: Scaling in x s_y: Scaling in y Translation in x and y kept as it was
Definition at line 116 of file vimt_transform_2d.h.
vimt_transform_2d& vimt_transform_2d::set_zoom_only | ( | double | s | ) | [inline] |
Sets the transformation to be a zoom.
x' = s.x + xt_, y' = s.y + yt_ s: Scaling Translation in x and y kept as it was
Definition at line 121 of file vimt_transform_2d.h.
void vimt_transform_2d::setCheck | ( | int | n1, |
int | n2, | ||
const char * | str | ||
) | const [private] |
Definition at line 181 of file vimt_transform_2d.cxx.
vimt_transform_2d & vimt_transform_2d::simplify | ( | double | tol = 1e-10 | ) |
Reduce to the simplest form possible.
Definition at line 108 of file vimt_transform_2d.cxx.
short vimt_transform_2d::version_no | ( | ) | const |
Definition at line 794 of file vimt_transform_2d.cxx.
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 593 of file vimt_transform_2d.cxx.
Form vimt_transform_2d::form_ [private] |
Definition at line 198 of file vimt_transform_2d.h.
bool vimt_transform_2d::inv_uptodate_ [mutable, private] |
Definition at line 202 of file vimt_transform_2d.h.
double vimt_transform_2d::tt2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::tt_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::tx2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::tx_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::ty2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::ty_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::xt2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::xt_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::xx2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::xx_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::xy2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::xy_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::yt2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::yt_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::yx2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::yx_ [private] |
Definition at line 197 of file vimt_transform_2d.h.
double vimt_transform_2d::yy2_ [mutable, private] |
Definition at line 201 of file vimt_transform_2d.h.
double vimt_transform_2d::yy_ [private] |
Definition at line 197 of file vimt_transform_2d.h.