目录

实验1-从点云中重建多边形边界

实验2-计算多边形域的近似中间轴

实验3-将2D网格变形为修改后的边界

1.加载数据。 要变形的网格由trife,xfe,yfe定义,它是面-顶点格式的三角剖分。

2.构造背景三角剖分-代表网格边界的点集的约束Delaunay三角剖分。

3.编辑背景三角剖分,以将所需的修改合并到域边界。

4.使用变形的背景三角剖分作为评估基础,将描述符转换回笛卡尔坐标。


实验1-从点云中重建多边形边界

此示例突出显示了使用Delaunay三角剖分从点云中重建多边形边界的方法。 重建基于优雅的Crust算法。

% Create a set of points representing the point cloud
numpts = 192;
t = linspace( -pi, pi, numpts+1 )';
t(end) = [];
r = 0.1 + 5*sqrt( cos( 6*t ).^2 + (0.7).^2 );
x = r.*cos(t);
y = r.*sin(t);
ri = randperm(numpts);
x = x(ri);
y = y(ri);% Construct a Delaunay Triangulation of the point set.
dt = delaunayTriangulation(x,y);
tri = dt(:,:);% Insert the location of the Voronoi vertices into the existing
% triangulation
V = dt.voronoiDiagram();
% Remove the infinite vertex
V(1,:) = [];
numv = size(V,1);
dt.Points(end+(1:numv),:) = V;% The Delaunay edges that connect pairs of sample points represent the
% boundary.
delEdges = dt.edges();
validx = delEdges(:,1) <= numpts;
validy = delEdges(:,2) <= numpts;
boundaryEdges = delEdges((validx & validy), :)';
xb = x(boundaryEdges);
yb = y(boundaryEdges);
clf;
triplot(tri,x,y);
axis equal;
hold on;
plot(x,y,'*r');
plot(xb,yb, '-r');
xlabel('Curve reconstruction from a point cloud', 'fontweight','b');
hold off;

效果图如下:


实验2-计算多边形域的近似中间轴

% Construct a constrained Delaunay triangulation of a sample of points
% on the domain boundary.
load trimesh2d
dt = delaunayTriangulation(x,y,Constraints);
inside = dt.isInterior();% Construct a triangulation to represent the domain triangles.
tr = triangulation(dt(inside, :), dt.Points);% Construct a set of edges that join the circumcenters of neighboring
% triangles; the additional logic constructs a unique set of such edges.
numt = size(tr,1);
T = (1:numt)';
neigh = tr.neighbors();
cc = tr.circumcenter();
xcc = cc(:,1);
ycc = cc(:,2);
idx1 = T < neigh(:,1);
idx2 = T < neigh(:,2);
idx3 = T < neigh(:,3);
neigh = [T(idx1) neigh(idx1,1); T(idx2) neigh(idx2,2); T(idx3) neigh(idx3,3)]';% Plot the domain triangles in green, the domain boundary in blue and the
% medial axis in red.
clf;
triplot(tr, 'g');
hold on;
plot(xcc(neigh), ycc(neigh), '-r', 'LineWidth', 1.5);
axis([-10 310 -10 310]);
axis equal;
plot(x(Constraints'),y(Constraints'), '-b', 'LineWidth', 1.5);
xlabel('Medial Axis of a Polygonal Domain', 'fontweight','b');
hold off;

效果图如下:

实验3-将2D网格变形为修改后的边界

1.加载数据。 要变形的网格由trife,xfe,yfe定义,它是面-顶点格式的三角剖分。

load trimesh2d
clf;
triplot(trife,xfe,yfe);
axis equal;
axis([-10 310 -10 310]);
axis equal;
xlabel('Initial Mesh', 'fontweight','b');

效果图如下:

2.构造背景三角剖分-代表网格边界的点集的约束Delaunay三角剖分。

对于网格的每个顶点,计算一个描述符,以定义其相对于背景三角剖分的位置。 描述子是包围的三角形以及相对于该三角形的重心坐标。

dt = delaunayTriangulation(x,y,Constraints);
clf;
triplot(dt);
axis equal;
axis([-10 310 -10 310]);
axis equal;
xlabel('Background Triangulation', 'fontweight','b');
descriptors.tri = pointLocation(dt,xfe, yfe);
descriptors.baryCoords = cartesianToBarycentric(dt,descriptors.tri, [xfe yfe]);

效果图如下:

3.编辑背景三角剖分,以将所需的修改合并到域边界。

cc1 = [210 90];
circ1 = (143:180)';
x(circ1) = (x(circ1)-cc1(1))*0.6 + cc1(1);
y(circ1) = (y(circ1)-cc1(2))*0.6 + cc1(2);
tr = triangulation(dt(:,:),x,y);
clf;
triplot(tr);
axis([-10 310 -10 310]);
axis equal;
xlabel('Edited Background Triangulation - Hole Size Reduced', 'fontweight','b');

效果图如下:

4.使用变形的背景三角剖分作为评估基础,将描述符转换回笛卡尔坐标。

Xnew = barycentricToCartesian(tr,descriptors.tri, descriptors.baryCoords);
tr = triangulation(trife, Xnew);
clf;
triplot(tr);
axis([-10 310 -10 310]);
axis equal;
xlabel('Morphed Mesh', 'fontweight','b');

效果图如下:

Matlab之有趣实验之画多边形图相关推荐

  1. matlab 绘多图 图名,MATLAB中subplot函数来画多图

    登录后查看更多精彩内容~ 您需要 登录 才可以下载或查看,没有帐号?立即注册 x 在用matlab中subplot函数时,为什么会出现缺图的现象? 单独运行每一个图都可以,但是放在一起就不行,下面是我 ...

  2. matlab画完图之后,Matlab的1个figure画多图在画最后1张图时整个图突然变乱了?

    在一个figure中画多张图出现下面的情况: 画前三个图时(图一)还正常(为了避嫌用画图板处理了一下),再画第四个整个figure(图二)就突然变乱了 .而且单独画第四个figure(图三),它的位置 ...

  3. matlab中应用surf函数画球形物体的三维坐标变换,从球坐标系转换到笛卡尔坐标系

    在Matlab中采用surf函数画三维图时,该函数使用笛卡尔坐标系绘制图形,因此在某些球形图案的绘制中,直接使用(theta,phi,z)参数无法得到球形图案,需要将图案对应的点从球坐标转变为笛卡尔坐 ...

  4. matlab绘图z=sin(x_「matlab画三维图」Matlab 应用之绘制三维图形(基础篇) - seo实验室...

    matlab画三维图 在Matlab中,三维图形的绘制包括三维曲线,三维网线图和三维曲面图.闲话不多说,直接进入正题.首先介绍几个函数: 1.plot3(x,y,z,-) 其中,x,y,z为维数相同的 ...

  5. matlab如何画波特图,matlab画波特图

    Matlab 中 Bode 图的绘制技巧 学术收藏 2010-06-04 21:21:48 阅读 54 评论 0 字号:大中小 订阅 我们经常会遇到使用 Matlab 画伯德图的情况,可能我们我们都. ...

  6. matlab simulink波特图,用simulink画波特图

    我们经常会遇到使用 Matlab 画伯德图的情况,可能我们我们都知道 bode ... MATLAB绘制Bode图与Nyqu... 3页 1下载券 浅议用Matlab绘制Bode图... 2页 2下载 ...

  7. 使用Pysot和MATLAB目标跟踪画对比图,标注框

    使用Pysot和MATLAB目标跟踪画对比图,标注框 python画图点会掉,MATLAB点会涨,具体什么原因,我也不知道!!! 最近也是在画图,搞了很久.翻了很多博客,才弄好.哈哈,在很多博客留下了 ...

  8. matlab泰勒图,matlab画泰勒图

    急 在matlab中写个用泰勒级数计算arctan(x)的方程 clear;clc;x=1;s=0;y=atan(x);fori=1:1e6n=2*i-1;s=s+(-(-1)^i)*(x^n)/n; ...

  9. Matlab中用Simulink快速画Bode图及 .m 文件画Bode图

    Matlab中用Simulink快速画Bode图及 .m 文件画Bode图 Simulink画Bode图 .m 文件画Bode图 Simulink画Bode图 一万年没用matlab画过Bode图了, ...

最新文章

  1. R语言指数分布(exponential distribution)函数(dexp, pexp, qexp rexp)实战
  2. Geospark空间查询
  3. 浅谈JavaScript中的事件
  4. C++中返回对象的情形及RVO
  5. Even for transaction data request, metadata is still needed as prerequisite
  6. Linux 安装Eclipse
  7. Linux下的网络协议分析工具-tcpdump快速入门手册
  8. java疯狂讲义笔记整理(第二版第一部分)
  9. 华为安装gsm框架_华为Mate30Pro怎么安装谷歌服务框架?谷歌服务GMS框架安装方法...
  10. php 应用截图,PHP实现网页截图?
  11. Java-Thread-Affinity框架使用及原理分析
  12. 值得回忆2012年-飘渺的2013年
  13. vue路由跳转总是跳转到首页,路由匹配不上
  14. echarts实现地图飞线
  15. complex函数python_Python中complex函数有什么用?
  16. 推荐算法工程师学习路线及工作指南
  17. 《Google Android开发入门与实战随书视频》
  18. 通用寄存器介绍和段寄存器的介绍
  19. oracle踩的那些坑
  20. 月球公转与自转(一)

热门文章

  1. crm系统如何帮助企业提升客户满意度?
  2. puppet基础学习(一)
  3. boost::filesystem使用入门体验
  4. 比尔盖茨和女秘书的姻缘故事(转载)
  5. DNS WEB URL HTTP总结
  6. FOMO3D 资料大全
  7. Mybatis判断空字符串
  8. 干货!如何用Python处理图像,一文带你了解!
  9. 搭建CDH 阿里云 (Step 3: 搭建Hive)
  10. 图论(11)非H图特征及TSP问题