(三)CGAL库应用:仿射变换(点的旋转、平移、放大)

因为某些时候需要点的坐标进行平移、旋转、缩放,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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值