简体   繁体   English

关于Voronoi图

[英]Regarding Voronoi diagram

In MATLAB's function of Voronoi diagram, the vertices of edges at infinity are plotted at some distant point. 在MATLAB的Voronoi图功能中,无限远处的边的顶点绘制在某个远点处。 Have a look at the first diagram on the page here . 这里查看页面上的第一个图。 The first point from the top on Y-axis is (0,0.75). Y轴从顶部开始的第一个点是(0,0.75)。 (Though it is extended beyond the bounds of the image). (尽管它超出了图像的范围)。 I know if I run the following matlab function: 我知道是否运行以下matlab函数:

[vx,vy]=voronoi(x,y)

I can get the coordinates of the vertices, but they will be beyond the bounds of the plot. 我可以得到顶点的坐标,但是它们将超出绘图范围。 Is there any way to get the coordinate in bounds of the plot (for example, (0,0.75) as mentioned above). 是否有任何方法可以获取绘图范围内的坐标(例如,如上所述(0,0.75))。

All you need is to detect which of the vx,vy crosses the axes (using find or logical conditions, find(vx<0) , find(vy>1) etc...) , and then apply the equation of the line y=a*x+b . 您所需vx,vy就是检测哪个vx,vy与轴交叉(使用find或逻辑条件,使用find(vx<0)find(vy>1)等...),然后应用线y=a*x+b的等式y=a*x+b For the point you wanted (which happens to be the 19th col of vx,vy , the slope a is: 对于您想要的点(恰好是vx,vy的第19列,斜率a为:

a=diff(vy(:,19))/diff(vx(:,19));

and the intersection with y axis is given by b : 与y轴的交点由b给出:

b=vy(1,19)-a*vx(1,19) B = VY(1,19)-a * VX(1,19)

b =
    0.7546

To calc b I picked the first point [vx(1,19),vy(1,19)] but this of course works also for the second point, ie b=vy(2,19)-a*vx(2,19) 为了计算b我选择了第一个点[vx(1,19),vy(1,19)]但这当然也适用于第二个点,即b=vy(2,19)-a*vx(2,19)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM