用matlab mpt工具箱生成受限的voronoi图.请问该怎么得到各个顶点坐标呢(包括voronoi边与边界的交点)?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 10:56:50
用matlab mpt工具箱生成受限的voronoi图.请问该怎么得到各个顶点坐标呢(包括voronoi边与边界的交点)?
用matlab mpt工具箱生成受限的voronoi图.请问该怎么得到各个顶点坐标呢(包括voronoi边与边界的交点)?
用matlab mpt工具箱生成受限的voronoi图.请问该怎么得到各个顶点坐标呢(包括voronoi边与边界的交点)?
extreme这个函数就可以得到顶点坐标.
给你个代码:
function irPoly = getIrreg(m,s)
%GETIRREGULAR Summary of this function goes here
% get irregular pixels
% the same begin & end
% clockwise order
% m - regular size
% S - low/high resolution
% get limit voronoi
x = gallery('uniformdata',[(m*s)^2 1],0);
y = gallery('uniformdata',[(m*s)^2 1],1);
vOut = [0,0; 0,m; m,m; m,0];
P = polytope(vOut);
Options.pbound = P;
% Options.plot = 1;
Pn = mpt_voronoi(m*[x,y],Options);
% split each polygon
for iPoly = 1:length(Pn)
thisPoly = extreme(Pn(iPoly));
% limited in [0,m]
thisPoly(thisPoly>m) = m;
thisPoly(thisPoly