Algorithm to cover maximal number of points with one circle of given radius

后端 未结 10 1516
Happy的楠姐
Happy的楠姐 2020-12-23 14:19

Let\'s imagine we have a plane with some points on it. We also have a circle of given radius.

I need an algorithm that determines such position of the circle that it

相关标签:
10条回答
  • 2020-12-23 14:42

    At a first glance, I would say a quad tree solution.

    Also, there is an information visualization/Data mining method called K-means which makes clusters of given data. It can be used with added functionality in the end to fit your purpose.

    The basic algorithm for K-Means is:

    1. Place K points into the space represented by the items that are being clustered - These points represent initial group centroids
    2. Assign each data item to the group that has the closest centroid
    3. When all items have been assigned, recalculate the positions of the K centroids by calculating the mean position of your dots
    4. Repeat Steps 2 and 3 until the centroids no longer move, or move very little

    The added functionality would then be:

    1. Calculate number of points within your circle positioned at the K centroids
    2. Choose the one that suits you the best ;)

    Sources:
    K-means algorithm - Linköping University
    Quadtree - en.wikipedia.org/wiki/Quadtree

    A quick search on wikipedia and you find source code: en.wikipedia.org/wiki/K-means_clustering

    0 讨论(0)
  • 2020-12-23 14:43

    You could pixelize the whole area, then go to each point and increase the value of all pixels within the circle of the radius around that point. The pixels with the highest sum are good candidates.

    Of course, you might lose some good areas or "hallucinate" good areas due to rounding errors. Perhaps you could try to do a rough pixellation first, then refine the promising areas.

    0 讨论(0)
  • 2020-12-23 14:45

    Edited to better wording, as suggested :

    Basic observations :

    • I assume the radius is one, since it doesn't change anything.
    • given any two points, there exists at most two unit circles on which they lie.
    • given a solution circle to your problem, you can move it until it contains two points of your set while keeping the same number of points of your set inside it.

    The algorithm is then:

    • For each pair of points, if their distance is < 2, compute the two unit circles C1 and C2 that pass through them.
    • Compute the number of points of your set inside C1 and C2
    • Take the max.
    0 讨论(0)
  • 2020-12-23 14:47

    This is the "disk partial covering problem" in the literature -- that should give you a good place to start googling. Here's a paper covering one possible solution, but it is a little intense mathematically: Approximation Algorithms Design for Disk Partial Covering Problem

    As a matter of fact, this falls in the area called computational geometry, which is fascinating but can be hard to get a toehold in. There's a good overview by deBerg on various algorithms related to the subject.

    0 讨论(0)
提交回复
热议问题