How to update delaunay triangulation in 2D? - geometry

What is the best way to update a current delaunay triangulation when the points moved a bit further ? Is it possible to update it, always with just flipping the sides or in some cases we need more complicated changes like remove/insert of a point ?

Related

Most efficient and effective way to create a surface from 3d points

Say I had a point cloud with n number of points in 3d space(relatively densely packed together). What is the most efficient way to create a surface that goes contains every single point in it and lets me calculate values such as the normal and curvature at some point on the surface that was created? I also need to be able to create this surface as fast as possible(a few milliseconds hopefully working with python) and it can be assumed that n < 1000.
There is no "most efficient and effective" way (this is true of any problem in any domain).
In the first place, the surface you have in mind is not mathematically defined uniquely.
A possible approach is by means of the so-called Alpha-shapes, implemented either from a Delaunay tetrahedrization, or by the ball-pivoting method. For other methods, lookup "mesh reconstruction" or "surface reconstruction".
On another hand, normals and curvature can be computed locally, from neighbors configurations, without reconstructing a surface (though there is an ambiguity on the orientation of the normals).
I could suggest Nina Amenta's Power Crust algorithm (link to code), or also meshlab suite, which can compute the curvatures too.

"Inverting" a concave polygon

I'm building a 2D game where player can only see things that are not blocked by other objects. Consider this example on how it looks now:
I've implemented raytracing algorithm for this and it seems to work just fine (I've reduced the boundaries for demo to make all edges visible).
As you can see, lighter area is built with a bunch of triangles, each of them having common point in the position of player. Each two neighbours have two common points.
However I'm willing to calculate bounds for external the part of the polygon to fill it with black-colored triangles "hiding" what player cannot see.
One way to do it is to "mask" the black rectangle with current polygon, but I'm afraid it's very ineffective.
Any ideas about an effective algorithm to achieve this?
Thanks!
A non-analytical, rough solution.
Cast rays with gradually increasing polar angle
Record when a ray first hits an object (and the point where it hits)
Keep going until it no longer hits the same object (and record where it previously hits)
Using the two recorded points, construct a trapezoid that extends to infinity (or wherever)
Caveats:
Doesn't work too well with concavities - need to include all points in-between as well. May need Delaunay triangulation etc... messy!
May need extra states to account for objects tucked in behind each other.

Manual Triangulation in Point Cloud Library

I have a point cloud, and I have performed a plane detection. Now I want to triangulate the scene.
I already have the triangulation of each plane, which looks like this :
I want to use Point Cloud Library GreedyProjectionTriangulation in order to reconstruct the scene. So I want to adapt the different functions which intervene in the reconstruction.
I dug in the code of gp3.h and gp3.hpp (which can be found in pcl/surface/include/pcl/surface) and read the associated publication. So far I have come to this :
Every point of my planes should be marked as fringe at the very beginning - and it is easy to do so with the vector state_.
We add triangles of the planes with the function addTriangles, no problem with this.
I don't know how to enforce the edges. There is a doubleEdges vector, but I didn't really understand how it worked. It seems that it is reseted for every iteration on a point.
I have to push the points of my planes in the fringe_queue_ vector, but the addFringe function is weird, since it asks for 2 arguments and I don't understand why.
I didn't understand what the vector part_ was for.
My current result is this :
It is not very clear on the image, but since I don't know how to enforce edges, I have issues of overlapping triangles.
EDIT
I continue to dig in the code. I identified what the crucial part may be. To avoid a wall of code, you can find the interesting part here - it is approximately between line 180 and 285 in gp3.hpp.
I can't understand what sfn_ and ffn_ are for. My intuition is that sfn_[R_] returns the second fringe neighbor of R_, and ffn_[R_] returns the first fringe neighbor of R_. So something like this :
If I'm right, I can easily to do this, since I have the contour of my plane sorted in the right order.
I still don't know how to enforce edges of my triangles belonging to my plane. Looking at the code, I think the key is in the doubleEdges vector, but I don't know how to modify this part to make it relevant for my problem.

What's the opposite of tesselation?

From what I understand, taking a polygon and breaking it up into composite triangles is called "tesselation". What's the opposite process called and can anyone link me to an algorithm for it?
Essentially, I have a list of 2D triangles and I need an algorithm to recombine them into a polygon.
Thanks!
I think you need to transform your triangles as a half edge data structure, and then you should be able to easily find the half edges which have no opposite.
It's called mesh decimation. Here is some code I wrote to do this for a class. Tibur is correct that the half edge data structure makes this much more efficient.
http://www.cs.virginia.edu/~mjh7v/advgfx/proj1/
The thing that you are calling tessellation is actually called triangulation. The thing you are searching for is tessellation (you may have heard of it referred to as tiling).
If you are more specific about the problem you are trying to solve (e.g. do you know the shape of the final polygon?) I can try to recommend some more specific algorithms.

How do I arbitrarily distort a textured polygon?

I'd like to write a program that lets me arbitrarily distort a textured polygon by dragging its vertices. I want the texture to distort fluidly and without overlap, assuming the new polygon doesn't intersect itself. I should also be able to repeat the process with the new shape, and with a minimum amount of loss.
Are there any algorithms for doing this?
It sounds like you might want a variation on the Schwarz-Christoffel mapping. This is a type of conformal mapping that can be used to warp a polygon to and from a simpler region, like a disk; although I have not implemented it, apparently it is computationally tractable.
For your application, you would set up a map from the original polygon to the simpler region, and compute the inverse map to the modified polygon; combining the two should give you a nice conformal mapping from the original to the modified polygon.
Conformal mappings are nice and smooth, but they can sometimes behave in unintuitive ways; I can imagine that an animated version might yield some entertaining "slidy" effects. The conformal mapping will preserve local angles in the interior of the polygon; this means that the size distortion very near a modified vertex can be severe.
People have been working on solutions to this problem for the past decade or two, and the state of the art keeps on getting better and better (but the math gets harder as well). A good place to start (and sort of where I stopped following it) is the work http://www.cs.technion.ac.il/~weber/Publications/Complex-Coordinates/
Read the paper there, and look up the papers in the references. One of them should give you an algorithm that you're willing to implement.
The simplest method I can think of is to triangulate the input polygon (using an ear clipping method, or something similarly good) and then move the points. Then you can use a barycentric mapping from the original polygon to the new space.
If you're looking for something more robust, you might look at mean value coordinates.

Resources