Merging two Convex Hulls with minimum perimeter - algorithm

assume that we have two (or more) convex hulls in the plane and we want merging them. but the convex hull result has minimum perimeter. is any algorithm available for this?

You can run any optimized convex hull algorithm on the boundary point of two convex hulls, you should get a new convex hull covering both of the previous ones. To maintain the convex property, there will be a unique resultant convex hull, so the minimum perimeter should not be a constraint.

Split all K hulls in upper and lower hulls. Now you have 2K sorted sequences of vertices. Merge the upper and lower sequences separately, using a K-way merge. This is done in time O(N log(K)) where N is the total number of vertices.
Now two Graham scans give the global hulls in time O(N).
[This is an adaptation of the monotone-chain algorithm.]

Related

Complexity of the vertices of a decomposed simple polygon to its cells

Given a simple polygon (without holes), consider a given decomposition of the polygon into convex sub-polygons. Suppose there are m number of convex sub-polygons and the number of the vertices of the decomposed grid is v. I am looking for the complexity of v in m.

Fastest algorithm to compute the shortest distance between 2 regions of set of points [duplicate]

I want to find the minimum distance between two polygons with million number of vertices(not the minimum distance between their vertices). I have to find the minimum of shortest distance between each vertex of first shape with all of the vertices of the other one. Something like the Hausdorff Distance, but I need the minimum instead of the maximum.
Perhaps you should check out (PDF warning! Also note that, for some reason, the order of the pages is reversed) "Optimal Algorithms for Computing the Minimum Distance Between Two Finite Planar Sets" by Toussaint and Bhattacharya:
It is shown in this paper that the
minimum distance between two finite
planar sets if [sic] n points can be
computed in O(n log n) worst-case
running time and that this is optimal
to within a constant factor.
Furthermore, when the sets form a
convex polygon this complexity can be
reduced to O(n).
If the two polygons are crossing convex ones, perhaps you should also check out (PDF warning! Again, the order of the pages is reversed) "An Optimal Algorithm for Computing the Minimum Vertex Distance Between Two Crossing Convex Polygons" by Toussaint:
Let P = {p1,
p2,..., pm} and Q = {q1, q2,...,
qn} be two intersecting polygons whose vertices are specified
by their cartesian coordinates in
order. An optimal O(m + n)
algorithm is presented for computing
the minimum euclidean distance between
a vertex pi in P and a
vertex qj in Q.
There is a simple algorithm that uses Minkowski Addition that allows calculating min-distance of two convex polygonal shapes and runs in O(n + m).
Links:
algoWiki, boost.org, neerc.ifmo.ru (in russian).
If Minkowski subtraction of two convex polygons covers (0, 0), then they intersect

Point location in 3D convex polyhydron

Let P be a 3D convex polyhedron with n vertices.
1. Given an algorithm that takes an arbitrary point q as input, how can I decide in O(n) time whether q is inside or outside the convex polyhedron?
2. Can I do some processing to make it O(logn)?
For (1), if you have a convex polyhedron with n vertices then you have also O(n) faces. One could triangulate each face and in total it would still be O(n) triangles. Now take the query point q and check on which side of a triangle q lies. This check takes O(1) for one triangle, thus O(n) for all triangles.
EDIT: The O(n) faces define O(n) planes. Just check if q lies on the same side for all planes.
For (2), (I did not find source for this but it seem reasonable) one could project the polyhedron P as P' onto a plane. P' can be seen as two separate planar graphs, one graph U' for the upper part of the polyhedron and the second graph L' for the lower part. In total there are O(n) faces in L' and U'. Now one can preprocess L' and U' via Kirkpatrick optimal planar subdivision algorithm. (Other sources for it: 1 and 2) This enables O(log n) point in PSLG (planar straight line graph) checks.
Now using the query point q and projecting it to the same plane with the same projection one can look up the face of L' and U' it lies in in O(log n) time. In 3D each face lies in exactly one plane. Now we check on which side q lies in 3D an know if q is inside the polyhedron.
Another approach for (2) will be spacial subdivision of the polyhedron into slubs - pyramids with their vertex in the polyhedron centroid and polyhedron faces as their bases. Number of such slabs is O(n). You can build a binary space partitioning tree (BSP), consisting of these slubs (probably divided into sub-slubs) - if it's balanced, then the point location will work in O(logn) time.
Of course, it will make sense, if you need to call the point location function many times - because the pre-processing step here will take O(n) time (or more).

Checking if point set triangle subdivision is a triangulation

I've been studying Delaunay triangulation (not a homework) and I thought about the following problem : given a set of points S on plane (with cardinality of n) and a set of triangles T (should be with the cardinality of n-2) — how to determine if the triangles set T form a Delaunay triangulation DT(S)?
The first problem is that Delaunay triangulation is not unique, so rebuilding it for the points set again and comparing to the triangles set won't give us the answer. In addition, optimal Delaunay triangulation algorithms are rather hard to implement (however, using libraries like CGAL would have been okay).
Suppose we know how to check if the triangles set is a triangulation (not necessarily Delaunay). Then we should use the definition of a Delanuay triangulation: for every triangle t in triangulation, no point in S is strictly inside the circumference of t. This leads us to the following methods:
The trivial approach. Just iterate over T, compute the circumference and iterate over S, checking if point is inside the circumference. However, this takes O(n^2) time, which is not very optimal.
The enchanted approach. Again, iterate over T and compute the circumference. If any point s in inside the circumference, it means that its distance to the circumference center is less than the radius. Using nearest neighbour searching structures over S, we will speed up our algorithm. For instance, simple kd-tree structure leads us to O(n log n) algorithm in average and O(n sqrt(n)) in the worst case.
Does anyone have an idea of something simpler?
Now let's return to the problem of checking if T is a triangulation at all. Trivial pre-requirements like equality of S and the set of triangles' vertices can be performed no faster than O(n log n). What is left — to check that every two triangles in T intersect in a common face, or not at all.
Again, we could do this by iterating over T and again over T, checking for intersection, but this is O(n^2) algorithm.
Let's think about what «triangles t1 and t2 intersect» mean? They intersect if their edges intersect or if one triangle is completely lies in another. The problem of intersecting all the edges can be solved at O(n log n) time using Bentley-Ottmann algorithm (the worst case is O((n + k) log n), where k is the count of intersections, but we can stop the algorithm at the moment we find the first intersection). Also we didn't recognize the case of one triangle completely containing another, but I believe we can modify Bentley-Ottmann algorithm to maintain triangles crossing the sweep line instead of segments, which as I said, yields us O(n log n) algorithm. However, it is really complex to implement.
I've thought about iterative algorithm — let's maintain the structure of non-intersecting (or only intersecting by edge) triangles (it should be something very similar to kd-tree). Then we try to add the next triangle t: first check if any of t's vertices is already in one of the triangles — then we got an intersection. Otherwise, add t to the structure. However, if we want O(log n) or O(sqrt(n)) time for search and add queries, we have to balance this structure's height, which is too hard even for kd-trees.
So, does anyone know any simple solution to this problem?
There is a Delaunay lemma : "If every edge in a triangulation K of S is locally Delaunay then K is the Delaunay triangulation of S". Maybe this could help in situation from paragraph 1 of your question, where you are certain that K is some triangulation of S. Dunno the computational complexity of this approach though.

parallel convex hull algorithm in gpu

I am implementing a divide and conquer approach to convex hull in CUDA. This is my approach:
Bottom up:
Create a list of lists to store convex hulls;
curSize = size of input (all points);
for i: 1 to log N
begin
curSize = curSize / 2;
Take every 2 adjacent convex hulls in list of lists and merge them
into bigger hull (using standard upper and lower common tangent
approach for Divide & Conquer Convex hull) in curSize threads
//Initially it merges every 2 adjacent points in list to a hull, then
in next iteration, it merges convex hulls of size 2 into bigger
convex hulls and so on.., finally the list of lists will have a
single list of points on the hull
end
But its getting too complicated and I feel I am not utilizing the parallel power of CUDA as at every level of the tree I create N/2^i threads whose complexity is O(N) in merging all adjacent hulls at this level. Hence net complexity is still O(N logN).
Can you tell me how to make it better or give any alternative neater parallel algorithm for convex hull (it'll be great if I can get algorithm for parallel version of graham's scan)?
The complexity of your algorithm is still O(N) (not changed in comparison to one-threaded version) because you make 3 things:
Manage threads: O(N)
Remove some vertices from lists: amortized O(N) since there are only N points.
Look at points adjacent to removed, but not removed during current step: O(N) since there are not more than 2 such points for each merge.
But if your points are not sorted, you should better parallelize sorting.

Resources