【CGAL_网格处理】坐标变换
官方手册阅读
文档函数链接:CGAL 5.5 - Polygon Mesh Processing: Polygon Mesh Processing Reference
transform()
template<class Transformation , class PolygonMesh , class NamedParameters = parameters::Default_named_parameters>
void CGAL::Polygon_mesh_processing::transform(const Transformation & transformation,PolygonMesh & mesh,const NamedParameters & np = parameters::default_values() )
包含头文件:#include <CGAL/Polygon_mesh_processing/transform.h>
函数实现功能:对PolygonMesh
中的每个顶点进行坐标变换。
Parameters | Details |
---|---|
transformation |
the transformation functor to apply to the points of mesh .
|
mesh |
the PolygonMesh to transform.
|
接下来分析一下参数类型:
- Transformation: 一个functor,能够对Point_3进行运算。可以是
CGAL::Aff_transformation_3
。 - PolygonMesh:a model of
VertexListGraph
其中,图概念VertexListGraph
是Boost里Graph概念的细化分支,添加了遍历图形中所有顶点的需求。通过查阅官方文档中CGAL and the Boost Graph Library部分,我们发现网格常用的Surface_mesh Class和Polyhedron Class在CGAL中均提供有部分特化,使其能成为图概念 BidirectionalGraph、VertexAndEdgeListGraph、AdjacencyMatrix 和 MutableFaceGraph
的模型。其中,VertexAndEdgeListGraph
就包括VertexListGraph, EdgeListGraph。
接下来再研究一下另一个参数类型Aff_transformation_3
。
Aff_transformation_3代表了三维空间下的仿射变换。其中使用数字类型 Kernel::RT
(homogeneous齐次坐标系)或者 Kernel::FT
(cartesian笛卡尔坐标系)来表示变换矩阵中的元素。
构造示例
- 平移
Aff_transformation_3 (const Translation, const Vector_3< Kernel > &v)
其中Translation是标记类,代表平移操作(此外还有Rotation、Reflection、Scaling等)。v是平移向量。
创建向Z方向平移的仿射变换。
CGAL::Aff_transformation_3<Kernel>(CGAL::Translation(), Kernel::Vector_3(FT(0), FT(0), FT(1)))
- 缩放
Aff_transformation_3 (const Scaling, const Kernel::RT &s, const Kernel::RT &hw=RT(1))
缩放大小计算 s / h w s/hw s/hw。
- 4x4矩阵构造
template<typename Kernel >
CGAL::Aff_transformation_3< Kernel >::Aff_transformation_3 ( const Kernel::RT & m00,const Kernel::RT & m01,const Kernel::RT & m02,const Kernel::RT & m03,const Kernel::RT & m10,const Kernel::RT & m11,const Kernel::RT & m12,const Kernel::RT & m13,const Kernel::RT & m20,const Kernel::RT & m21,const Kernel::RT & m22,const Kernel::RT & m23,const Kernel::RT & hw = RT(1) )
从如下矩阵
( m 00 m 01 m 02 m 03 m 10 m 11 m 12 m 13 m 20 m 21 m 22 m 23 0 0 0 h w ) \left(\begin{array}{cccc} m_{00} & m_{01} & m_{02} & m_{03}\\ m_{10} & m_{11} & m_{12} & m_{13}\\ m_{20} & m_{21} & m_{22} & m_{23}\\ 0 & 0 & 0 & hw \end{array}\right) ⎝ ⎛m00m10m200m01m11m210m02m12m220m03m13m23hw⎠ ⎞
构造一个仿射变换。
相关操作
Aff_transformation_3< Kernel > operator* (const Aff_transformation_3< Kernel > &s) const
重载了乘法运算符(*),可通过
tran1 * tran2
得到两个变换的组合变换。Aff_transformation_3< Kernel > inverse () const
求逆变换。
测试代码
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Aff_transformation_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/transform.h>
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;
using Vector_3 = typename Kernel::Vector_3;
using Polyhedron = CGAL::Polyhedron_3<Kernel>;
using Mesh = CGAL::Surface_mesh<Point_3>;
using Affine_transformation_3 = CGAL::Aff_transformation_3<Kernel>;
namespace PMP = CGAL::Polygon_mesh_processing;
int main()
{const std::string filepath = "meshes/blobby.off";Mesh mesh;CGAL::IO::read_OFF(filepath, mesh);Polyhedron polyhedron;CGAL::IO::read_OFF(filepath, polyhedron);CGAL::IO::write_STL("data/blobby.stl", polyhedron,CGAL::parameters::use_binary_mode(false));Affine_transformation_3 trans(FT(1), FT(0), FT(0), FT(0),FT(0), FT(1), FT(0), FT(0),FT(0), FT(0), FT(1), FT(1));PMP::transform(trans, polyhedron);CGAL::IO::write_STL("data/blobby_trans.stl", polyhedron,CGAL::parameters::use_binary_mode(false));return EXIT_SUCCESS;
}
【CGAL_网格处理】坐标变换相关推荐
- 【CGAL_网格】Surface_mesh
官方文档链接:CGAL 5.4.2 - Surface Mesh: User Manual 0 概述 Surface_mesh 类是半边数据结构的实现,可用于表示多面体表面. 相较于 Halfedge ...
- 【CGAL_网格处理】Isotropic Remeshing均匀化网格
原理 算法伪代码如下: remesh(target_edge_length)low = 4/5 * target_edge_lengthhigh = 4/3 * target_edge_lengthf ...
- 水面的简单渲染 – Gerstner波
发布于 2014年2月7日 作者: John Hany2,986次阅读 渲染三维场景时经常会遇到需要渲染各种水体的情况,比如湖泊.河流.海洋等,不仅需要水体表面要有接近真实的随时间而变化的波动,还要有 ...
- 二维几何基础大合集!《计算几何全家桶(一)》(基础运算、点、线、多边形、圆、网格)
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的模板整合计划 目录 1.基本运算 1.1 判断正负函数(sgn) 1.2 点积(数量积.内积)(Dot) 1.3 向量积 ...
- Open3d之坐标变换
Open3d的几何类型有许多种坐标变换的方法.在本节教程中我们将会展示如何使用旋转(rotate),平移(translate),缩放(scale)和变换(transform). 平移(translat ...
- matlab中应用surf函数画球形物体的三维坐标变换,从球坐标系转换到笛卡尔坐标系
在Matlab中采用surf函数画三维图时,该函数使用笛卡尔坐标系绘制图形,因此在某些球形图案的绘制中,直接使用(theta,phi,z)参数无法得到球形图案,需要将图案对应的点从球坐标转变为笛卡尔坐 ...
- 使用Matlab AppDesigner 进行飞行器坐标变换演示
1 原由 学习坐标变换需要有较强的空间想象能力,最好结合实际案例有一定的感性认识,否则坐标轴几经旋转后,凭空想象很难理解.为此,笔者使用Matlab AppDesigner 进行飞行器坐标变换演示GU ...
- M×N扫描序列图像拼接、大视场图像拼接、全景图像拼接、2D网格拼图方法、累计误差消除(显微图像/航拍图像等)
M×N扫描序列图像拼接.大视场图像拼接.全景图像拼接.2D网格拼图方法.累计误差消除(显微图像/航拍图像等) 前言 一.问题描述 二.拼接过程存在的问题 三.4种拼接算法介绍 1.搜索算法 2.最小生 ...
- 媲美Geomagic -- 一款高效、完备的点云和网格交互处理平台SXLib3D
链接:百度网盘 请输入提取码 提取码:k10c 全功能 拥有具备自主知识产权的数据处理平台 - SXLib3D,可满足视觉测量.光顺去噪.几何属性计算.多视对齐.变形交互.特征增强.网格封装.纹理 ...
最新文章
- 深入研究ConcurrentHashMap 源码从7到8的变迁
- 隧道接口工具airtun-ng
- iOS VideoToolbox硬编H.265(HEVC)H.264(AVC):1 概述
- 启明云端WT516P6Core离线语音模块发布后,开发者朋友提出的问题最多的是:是否可以自己编译指令
- selenium之如何使用cssSelector定位页面元素
- Mysql——Innodb和Myisam概念与数据恢复
- 双绞线直连法如何才能使两台电脑实现共享
- java如何生成验证码
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not avail
- 【统计学习】随机梯度下降法求解感知机模型
- ipad鼠标圆圈变成箭头_下一代 macOS 或将支持 Mac「投屏」到 iPad
- 带sex的net域名_sex.com(性)域名争夺再升级 色情能抵千万美金?
- ALSA声卡10_从零编写之数据传输_学习笔记
- ArcGIS API 4.x 加载高德底图
- Java Web项目开发项目经验总结
- hdlbits刷题记录
- 杭州,杭州……念兹在兹
- 《求职》第三部分 - 计算机网络篇 - 计算机网络总结
- iOS上传IPA时提示导入此构建版本时出错-errors occurred in the app thinning process
- 生活小技巧 | win10开热点给手机使用