Affine TransformationsWhat is an Affine Transformation?Transformations change the positions of points in the plane. A set of points, for example a rectangle, may acquire a different shape when transformed. The transformations that move lines into lines, while preserving their intersection properties, are special and interesting, because they will move all polylines into polylines and all polygons into polygons. These are called affine transformations. An affine transformation of the plane is specified by a 3x3 matrix
T with T2,0=T2,1=0
and T2,2!=0.It maps the point p
with the homogeneous coordinate vector
(px,py,pw)
to the point T*p. If T1 and T2 are transformations then T2(T1) is the transformation obtained by first applying T1 and then applying T2. Translations, rotations, and reflections are special cases of affine transformations. Practical ApplicationsAffine transformations play an important role, for example, in geographical information systems (GIS), where it is sometimes necessary to change the units of measurement, rotate a map, change the origin of a coordinate system, or remove a uniform distortion. ExampleThe following program shows how the LEDA data type #include <LEDA/geo/rat_transform.h> #include <LEDA/numbers/integer_matrix.h> using namespace leda; int main() { integer_matrix IM(3,3); IM(0,0)=1; IM(0,1)=0; IM(0,2)=1; IM(1,0)=0; IM(1,1)=2; IM(1,2)=1; IM(2,0)=0; IM(2,1)=0; IM(2,2)=1; rat_transform T(IM); //maps (0,1) to (1,3), (1,2) to (2,5), (2,3) to (3,7), ... std::cout << "General Transformation:" << std::endl; int i; for (i=0;i<10;i++) { rat_point p(i,i+1); rat_point q=T(p); std::cout << p.to_point() << " " << q.to_point() << std::endl; } TRANSFORM TROT=rotation90(point(0,0)); std::cout << std::endl << "Rotation about origin by 90 degrees:" << std::endl; for (i=0;i<10;i++) { rat_point p(i,i+1); rat_point q=TROT(p); std::cout << p.to_point() << " " << q.to_point() << std::endl; } return 0; } |
See also:Double Valued Vectors and Matrices Cartesian and Homogeneous Coordinates Writing Kernel Independent Code Advanced Data types for 2-D geometry Manual Entries: |