因为某些时候需要点的坐标进行平移、旋转、缩放,cgal库也以kernel object的形式提供了仿射变换,就和点、线段、向量、矩形一样,仿射变换也是这样类似的几何kernel object,定义在头文件#include<CGAL/Aff_transformation_2.h>中,以下代码是针对点的简单的旋转、平移和放大,而且cgal也提供了仿射变化的相关运算,得到复合的仿射变换,最后得到的结果是一样的,运行结果如图所示。
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include<CGAL/Aff_transformation_2.h>
#include<fstream>
#include<iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Aff_transformation_2 Transformation;
typedef K::Point_2 Point;
typedef K::Vector_2 Vector;
using namespace std;
int main(int argc, char *argv[]){
Transformation transformation_ROTATION(CGAL::ROTATION,sin(3.1415/4),cos(3.1415 / 4));
Transformation transformation_TRANSLATION(CGAL::TRANSLATION, Vector(4, 0));
Transformation transformation_SCALING(CGAL::SCALING, 100);
Point A(1, 1);
Point B = transformation_ROTATION(A);
cout << B << endl;
B = transformation_TRANSLATION(B);
cout << B &l