3

I'm trying to implement Fortune's algorithm to construct a Voronoi diagram. I'm having trouble finding the parabola right above a seed point. How can I know which parabola will a vertical line (from the seed point) intersect? I'm using in DeBerg's "Algorithms and Applications" as reference.

iadvd
  • 8,875

2 Answers2

1

Taken from wikipedia https://en.wikipedia.org/wiki/Parabola .

I make the assumtion that the sweepline moves from top to bottom and that the position of the sweepline is decreasing.

Since you know know the points whose parabolas make up the beachline and you know the sweeplines y positions you can construct the formulas for the parabola. Given a point G and the sweepline position y we can calculate the shortest distance f between the parabola and the point or parabola and the sweepline. $$f = \frac{G_y - sweepline_y}{2}$$ Now we can construct the formula for the parabola of the given point G.

$$y = \frac{1}{4f}x^2 - \frac{G_x}{2f} x + \frac{G_x^2}{4f} + G_y+f$$

The vertical line will have formula of type x = C where C is some value.

To find the intersection point just plug the x into the parabola formula and you get the intersection point between the parabola and the vertical line.

Do this with all the parabolas and choose the one closest to the point.

  • 1
    Best answer so far, but this is not the quickest way. I think the parabolas should be in a binary search tree to speed up this step -- you have to compute the intersection between adjacent parabolas, and see between which intersection your new site lies in – Argemione Dec 22 '20 at 21:58
  • Yes. Binary search tree is the next step to take to improve performance.If you google a bit you can find quite in depth explanations of fortunes algorithm, although they can be rather complicated to understand, so more than one read through is needed. – Marko Taht Dec 23 '20 at 17:16
0

This answer provides an answer to part of the OP's inquiry, regarding the implementation of the algorithm.

I'm trying to implement Fortune's algorithm to construct a Voronoi diagram.

The OP wants to know how to make the calculations to make the implementation, so at least with this answer will be able to visualize the diagram and then verify that the calculations (if they are made manually) are correct.

This is a question also suitable for Stack overflow, but I have done a similar question in the past (see here) regarding the properties of the Voronoi diagram, so I am familiar with the methods to implement the algorithm you want.

Basically, nobody codes the calculations manually, you have a lot of programming languages already providing functions to make the process of the algorithm automatically.

In this case you have an example of a easy Python template, feel free to use it and modify it. If you are not familiar with Python, I strongly suggest you to learn it, at least the basic points. It is very helpful! If you are using other programming languages, at least the code will give you an idea of the way you need to write the implementation.

def Voronoi():
    import numpy as np
    import matplotlib.pyplot as plt
    from scipy.spatial import Voronoi, voronoi_plot_2d

    # example of point
    p1x = 0
    p1y = 0
    # This vector will include all the points of your Voronoi diagram
    fullvec = []
    fullvec.append([p1x,p1y])

    # add here as many points as you wish as above

    # convert the list to an numpy array 
    points = np.array(fullvec)

    # use the Voronoi library 
    vor=Voronoi(points)
    voronoi_plot_2d(vor)
    plt.show()

Voronoi()
iadvd
  • 8,875