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

编程入门 行业动态 更新时间:2024-10-28 14:23:14

(三)<a href=https://www.elefans.com/category/jswz/34/1651989.html style=CGAL库应用:仿射变换(点的旋转、平移、放大)"/>

(三)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 << endl;B = transformation_SCALING(B);cout << B << endl;Transformation transformation2 = transformation_SCALING*(transformation_TRANSLATION * transformation_ROTATION);Point C = transformation2(A);cout << C << endl;system("pause");return 0;
}

当然官网的文档可以看出,仿射变换的构造函数有很多种,官方文档传送门:.html#a47f305715cb75778048ea7329b5c02dc

更多推荐

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

本文发布于:2023-07-03 21:54:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1012498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CGAL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!