I have a region of space, 2 dimensions, from (0,0) to (MAX_X, MAX_Y).
Inside this region of space, I draw some lines, they intersect the perimeter of the region and they may intersect one another. In this way, these lines partition my region of space in subregions which, if summed, give the entire region of space.
Inside this region of space, there are some points (x,y). I have to determine
- the coordinates of all the vertices composing all the subregions of space created by the lines
- if a given subregion of space contains or not one or more of the points
I'm trying to code this in java, but the language is not really important. I don't have any idea about how to accomplish these two tasks. If anybody can give me an hint I'd really appreciate it.
That is indeed quite a math question. Thinking about the problem I assume that the solution will be quite complicated and/or expensive (computation-wise).
You start with a list R of subregions, starting with one element: the whole region. Next you loop over your list of lines. For every line you loop every R. If the line intersects the Region you divide it into two. Help on the line-area intersection check should be easily available on the net. Just look for intersections between a line and a convex area. The problem with this algorithm is that it will have a runtime of about O(n^3). O(n) for n lines times O(n) for the areas times O(n) for the intersection checks (however you might be able to speed that last part up significantly, bringing you down to O(n^2) in the end).
Checking which of your areas contains a specific point is classical problem of convex analysis. There should be algorithms available for that. I guess what you will be wanting to do is loop over your lines and check if your point is "left or right" of that line. If you link your subregions to your lines in the first step, this will give you the appropriate subregion in O(n).
The first problem can be solved considerably quicker with a more sophisticated algorithm and, like I said, the one I explained could be sped up significantly.
Basically if you want more information on the subject you are looking at convex analysis.
However, if all that doesn't help you at all, you are probably in over your head (no offense intended, you are handling really complicated math here).