find out a point is in which polygons - polygon

I have a region table in oracle 12c, the table include 9 region that each of them defined by a polygon.
Polygon defined by 4 points in 2D.
I give a point from client and I must find out that this point is in which polygon. can anyone help me with this problem?
by the way I use Oracle 12c.

Ray casting algorithm is a popular solution to your problem https://en.wikipedia.org/wiki/Point_in_polygon. You can find pseudo-code easily and can start from that.
If you want to have solution in a specific language, then sorry I can't be of help.

Related

Create graph of distinct routes

Problem I have a binary image with traversable and blocked cells. On this map points of interest (POIs) are set. My goal is to create a graph from these POIs respecting obstacles (see images) which represents all possible and truly distinct paths. Two paths are truly distinct if they can not be joined into one path. E.g. if the outside of the building in picture 1 was accessible a path around the building could not be merged with one through the building.
Researched I have looked at maze solvers and various shortest path finding algorithms (e.g. A*, Theta*, Phi*) and while they'd be useful for this problem they only search for a path between two points and don't consider already established routes.
Best Guess I am considering using Phi* to search for all possible routes and merge afterwards using magic (ideas?), but this will not give me truly distinct alternatives.
Can someone help?
P.S.: I'm using C++ and am not really eager to do this by myself, so if there is a library which already does this... :)
I found (and decided to use) a parallel thinning algorithm (Zhan-Suen for now) to create an image skeleton. This effectively makes the assumption that the geometry shapes the common routes, which is fine I think.
By using the Rutovitz crossing number I can extract bifurcations and crossings from the resulting skeleton. Then I'll determine the shortest line of sight from my Points of Interest (using Bresenham's algorithm) to the extracted crossings to connect them to the graph.
I hope this will help someone along the road :)

Split concave polygon in convex ones

Is there any easy algorithm to split a concave polygon in convex ones or represent a polygon by triangles. I know there is a Wikipedia entry on triangulation but this doesn't really help me. I know there already is a question on Stackoverflow, however this is not very helpful to me. I would appreciate any pseudocode (or real code in an understandable programming language) to break a concave polygon in convex ones or triangles. Btw, the algorithm should also work for convex polygons and not mess around with them.
Thanks for your help!
As proposed by the commenters, ear cutting (clipping) should be the most straight forward way to triangulate. To speed up the verifying process of an ear in practice one can employ a geometric grid.
To write robust and performant code, especially for geometric problems is very challenging. Why not use existing implementations like triangle or CGAL.
In order to use CGAL via python one could go for SWIG.

Get angle for ear clipping

I am trying to implement a ear clipping algorithm into a program of mine but I am having issues. While that I can get it to work in a lot of situations, I haven't found a good way to check for reflex angles.
I've been looking up ways - every method I've tried to date seems to have angle it won't work for. When I try to find more information, most people's tutorials/work just tell me to "find the reflex angle and test for ear" then describe how to test for ear but not how to get the reflex angle.
Can anyone tell me how to get the proper angle inside the triangle for a concave polygon, or point me in the right direction? Could be an understanding issue with me. Thanks.
Figured out my problem was one of how I was conceiving the issue. I was saying that if the point was outside the polygon it could still be in the polygon without adding in my head the fact I removed the last vertex. Been busting my brains trying to implement ear clipping for a few days and got it wrong at this point - the solution was the basic "check if the center point of the triangle was outside the polygon and mark it as reflex".

Hittest polygon

I have a 2d polygon that consists of a list with points, i want to check wether a given point lies in that polygon, but i cant find a good way to check this.
Can anyone point me in the right direction?
http://en.wikipedia.org/wiki/Point_in_polygon
http://alienryderflex.com/polygon/
this is a very very clear guide how to do that, inclusive a implementation in C

How to construct a mesh from given edge points?

I have some points on the edge(left image), and I want to construct a mesh(right), Is there any good algorithm to achieve it? many thanks!
image can see here http://ww3.sinaimg.cn/large/6a2c8e2bjw1dk8jr3t7eaj.jpg
To begin with, see Delauney triangulation. Look at this project: http://people.sc.fsu.edu/~jburkardt/c_src/triangulate/triangulate.html.
Edited because my original had too few details on edge-flipping, and when I tried to provided those details I found the TRIANGULATE project.
If the region is flat or quasi-flat look for Ear Clipping approach (http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf). In the case of curved surface you need point inside the region and therefore you may need Constrained Delaunay Triangulation (otherwise some edges may not be included in the triangulation).
There is delaunayn function in geometry package for R language (see doc)
It takes an array of boundary points (as in your case) to create a Delaunay mesh on it.
You could also save your geometry into some well-known format, and use one of mesh generators.

Resources