If the homogeneous representations are normalized such that the homogenizing coordinate is 1, then the upper left matrix realizes linear transformations and in the matrix form of a translation, the translation vector appears in the last column of the matrix. In the normalized case, entry is always 1. Entries and are always zero and therefore do not appear in the constructors.
#include <CGAL/Aff_transformation_2.h>
| |||
introduces a translation by a vector .
| |||
| |||
approximates the rotation over the angle indicated by direction
, such that the differences between the sines and
cosines of the rotation given by d and the approximating rotation
are at most each.
Precondition: .
| |||
| |||
introduces a rotation by the angle rho.
Precondition: .
| |||
| |||
introduces a scaling by a scale factor .
| |||
| |||
introduces a general affine transformation in the 3x3 matrix form .
The sub-matrix
contains the scaling and rotation information, the vector
contains
the translational part of the transformation.
| |||
| |||
introduces a general linear transformation , i.e. there is no
translational part.
|
The main thing to do with transformations is to apply them on geometric objects. Each class CGAL_Class_2<R> representing a geometric object has a member function:
CGAL_Class_2<R> transform(CGAL_Aff_transformation_2<R> t) .
The transformation classes provide a member function transform() for points, vectors, directions, and lines:
|
| |
|
| |
| ||
| ||
|
|
CGAL provides function operators for these member functions:
|
| |
|
| |
| ||
| ||
|
|
| ||
| composes two affine transformations. | |
| ||
| gives the inverse transformation. | |
|
| returns true, if the transformation is not reflecting, i.e. the determinant of the involved linear transformation is non-negative. |
|
| returns true, if the transformation is reflecting. |
The matrix entries of a matrix representation of a CGAL_Aff_transformation_2<R> can be accessed trough the following member functions:
|
| |
|
| |
returns entry in a matrix representation in which is 1. | ||
|
| |
|
| |
returns entry in some fixed matrix representation. |
For affine transformations no I/O operators are defined.
Affine transformations offer no transform() member function for complex objects because they are defined in terms of points vectors and directions. As the internal representation of a complex object is private the transformation code should go there.
typedef CGAL_Cartesian<double> RepClass; typedef CGAL_Aff_transformation_2<RepClass> Transformation; typedef CGAL_Point_2<RepClass> Point; typedef CGAL_Vector_2<RepClass> Vector; typedef CGAL_Direction_2<RepClass> Direction; Transformation rotate(CGAL_ROTATION, sin(pi), cos(pi)); Transformation rational_rotate(CGAL_ROTATION,Direction(1,1), 1, 100); Transformation translate(CGAL_TRANSLATION, Vector(-2, 0)); Transformation scale(CGAL_SCALING, 3); Point q(0, 1); q = rational_rotate(q); Point p(1, 1); p = rotate(p); p = translate(p); p = scale(p);
The same would have been achieved with
Transformation transform = scale * (translate * rotate); p = transform(Point(1.0, 1.0));