Creating Voronoi polygons diagram that are limited to a bounding box - python

I want to get a Voronoi polygon diagram for a set of points within 50 X 50 domain. That os all the voronoi ridges should be clipped at edges of bounding box, and voronoi vertices should lie on edges or within the bounding box.However this i the image I am getting by using scipy.spatial.Voronoi

The simplest way to cut off at the box boundaries all those cells that would extend beyond it is to do the following:
Reflect your original data set (your "Voronoi seeds") across each edge of your box, creating, in this case, 4 new data sets, each one being a mirror image of your original set of points across one of the edges.
Regard your original data set and these four new data sets as all one set of points, and run your Voronoi algorithm to create a Voronoi partition with this new, enlarged set. Those points in the original set whose cells would extend beyond the boundary now will be met by their mirror images, and their cells will be cut off exactly at the boundaries as you wish.
Now simply ignore the extra points generated in step 1, and you have a Voronoi partition of the original bounding box using only your original set of points, with the cells near the edge neatly cut off by the boundary of the box.
The reflection step is not hard; I can elaborate if necessary.
This method does multiply your number of points by 5, which increases the time to complete the Voronoi computation, obviously. Depending on your number of points, this could become an issue. One can speed things up by reflecting only those points whose cells actually extend beyond the box; that takes a bit more logic but is do-able.

Related

ABAQUS: History-Output with sets - is it possible to create sets trough points on a specific edge?

i am doing a parametric study in ABAQUS on a K-Joint with scuare hollow sections. Therefore i need to get the displacement between two points, see picture [KT-Joint location dial guages]. The connection area and the partition between the braces and the chord is done and looks like - see picture [K-Joint partitioning].
My Problem: If i do another partition with a XZ-Datum-Plane at the midaxis of the chord and then get the messure point along the surface edge (see picture [Partition with XZ-Datum-Plane]), the measure point will, dependent on the chord heigth, the gap size between the braces or the bracing angel, get on diffrent edges. This causes a rearrange of the edges designation and further the mesh gets disturbed.
Is it possible to get a geometric point (set) on the length of an edge without doing another partition? Or is there another option?
best greeting
Lukas
I tried to not seed the edge on the XZ-Partition and make it free. It worked until i changed the geometry.

Circle coordinates to cover larger circle in python

I am using Google Places API to find all cafes in a single area. Since the API maxes out at 60 results, I would need to apply some sort of grid search to cover the entire desired area.
I am looking for a python code where I could insert the objective coordinate (center of NY), desired large radius (5km), and small radius (0.5km). The algorithm would try identify the center coordinates of the smaller circles to cover the larger one completely. Output of the code would be list of coordinates of the smaller circles.
It doesn’t matter if the circles overlap each other or overflow the outer boundaries. This site had good visualizations of how the smaller circles could fill out the larger one https://math.stackexchange.com/questions/898247/the-minimum-number-of-circles-in-order-to-obtain-a-cover-of-a-specific-square

How to select the minimal set of circles that covers another circle?

I'm looking for some solutions that, given a set S of circles with 2D-center points and radii, returns a minimal sub-set M in S that covers entirely a specific circle with 2d-center point and radius. This last circle is not in S.
I've chosen circles, but it doesn't matter if we change them to squares, hexagons, etc.
You have two distinct problems: you need to turn the geometric problem into a combinatoric problem, and then you need to solve the combinatoric problem. For the latter, you are looking at a minimum set cover problem, and there should be plenty of literature on that. Personally I like Knuth's Dancing Links approach to enumerate all solutions of a set cover, but I guess for a single minimal solution you can do better. A CPLEX formulation (to match your tag) would use a binary variable for each row, and a ≥1 constraint for each column.
So now about turning geometry into combinatorics. All the lines of all your circles divide the plane into a bunch of areas. The areas are delimited by lines. Of particular relevance are the points where two or more circles meet. The exact shape of the line between these points is less relevant, and you might imagine pulling those arcs straight to come up with a more classical planar graph representation. So compute all the pair-wise intersections between all your circles. Order all intersections of a single circle by angle and connect them with graph edges in that order. Do so for all circles. Then you can do a kind of bucket fill to determine for each circle which graph faces are within and which are outside.
Now you have your matrix for the set cover: every graph face which is inside the big circle is a column you need to cover. Every circle is a row and covers some of these faces, and you know which.

Corner detection in an array of points

I get a pointcloud from my lidar which is basically an numpy array of points in 2D cartesian coordinates. Is there any efficient way to detect corners formed by such 2D points?
What I tried until now was to detect clusters, then apply RANSAC on each cluster to detect two lines and then estimate the intersection point of those two lines. This method works well when I know how many clusters I have (in this case I put 3 boxes in front of my robot) and when the surrounding of the robot is free and no other objects are detected.
What I would like to do is run a general corner detection, then take the points surrounding each corner and check if lines are orthogonal. If it is the case then I can consider this corner as feature. This would make my algorithm more flexible when it comes to the surrounding environment.
Here is a visualization of the data I get:
There are many many ways to do this. First thing I'd try in your case would be to chain with a reasonable distance threshold for discontinuities, using the natural lidar scan ordering of the points. Then it become a problem of either estimating local curature or, as you have done, grow and merge linear segments.

Unordered cloud point of polygon contour to polygon

Dear Stackoverflow community,
I have contours of irregular polygons as unordered datapoints (like on the figure here: https://s16.postimg.org/pum4m0pn9/figure_4.png), and I am trying to order them (ie. to create a polygon).
I cannot use the convex hull envelope because of the non convex shape of the polygon. I cannot ase a minimum distance criterion because some points of other parts of the contour lie closer (example: point A has to be joined with B, but is closer to C). I cannot use a clockwise ordering because of the irregular shape of the contour.
Do anyone knos a way to implement (preferentially in Python) an algorithm that would reorder the datapoints from a starting point?
look here finding holes in 2D point set for some ideas on how to solve this
I would create point density map (similar to above linked answer)
create list of all lines
so add to it all possible combination of lines (between close points)
not intersecting empty area in map
remove all intersecting lines
apply closed loop / connectivity analysis on the lines
then handle the rest of unused points
by splitting nearest line by them ...
depending on you map grid size and point density you may need to blend/smooth the map to cover gaps
if grid size is too big then you can miss details like on the image between points A,C
if it is too small then significant gaps may occur near low density areas
But as said this has more then one solution so you need to tweak this a bit to make the wanted output perhaps some User input for shaking the solution a bit until wanted solution found...
[notes]
you can handle this as more covex polygons ...
add line only if winding rule met
stop when no more lines found
start again with unused points
and in the end try to connect found non closed polygons ...

Categories