Question

In MATLAB's function of Voronoi diagram, the vertices of edges at infinity are plotted at some distant point. Have a look at the first diagram on the page here. The first point from the top on Y-axis is (0,0.75). (Though it is extended beyond the bounds of the image). I know if I run the following matlab function:

[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).

Was it helpful?

Solution

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. For the point you wanted (which happens to be the 19th col of vx,vy, the slope a is:

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

and the intersection with y axis is given by b:

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, i.e. b=vy(2,19)-a*vx(2,19)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top