• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Algorithm to determine a point inside irregular shape

Messages
217
Country
azerbaijan
Hi there,

I'm desperately looking forward to get your advice and recommendations to materialize an algorithm which, at a later stage, I could programmatically add to my project... Here is the case:

Imagine an arbitrary point (Point X) in space with the following properties:
# has coordinates
# lies on a 2D-surface
# is stationary
# belongs to a single area (boundary coordinates of which are also known) at any given time. Namely, it's the only "child" of its "parent" element. Again, if it doesn't sit in one area, it definitely sits inside another one!

An area is NOT a simple square, quadrangle, or a circle but instead is an irregular shape.

Now, my question is: How can I determine if Point X lies inside that particular area and NOT the adjacent one?!? I need a kind of a "TRUE" (inside) or "FALSE" (outside) type of an algorithm, if possible. See the attached image to better visualize the problem.

PS: I perused a possibility of dealing with the Point in Polygon (PIP) problem (especially, the "ray casting algorithm" is quite smart!) but it doesn't seem to be a solution since (i) segments of the area boundaries may have curvatures; (ii) areas may be adjacent to each other.

Thank you very much in advance!!!
 

Attachments

  • point_in_shape.png
    point_in_shape.png
    12.9 KB · Views: 530
Last edited:
I use PIP but then the areas in test are polys. One way, although messy would be to reduce the 'curves' to a series of straight lines so that something lines so something like PIP would work. Clearly the more points used to describe any curved edge the more accurate the result.
 
I use the swept angles from the point to each vertex of the polygon.
 
Summing. If the result is approximately zero, the point is outside.
 
I'll ask again... how is the shape being rendered? I assume it is being rendered?
 
I'll ask again... how is the shape being rendered? I assume it is being rendered?

I'm not sure that I follow your point here with rendering but... One of the implementations of this algorithm (finding a location of point inside an irregular shape) could be - for example - determining time zones simply by entering latitude and longitude of location. The source data to define the boundaries of time zones is easily available (e.g., Google's KML). Getting this to work without a robust algorithm is difficult though! :)

Btw, Google Maps uses its own timezone API which, of course, is proprietary and... useless for a developer like me.
 
Last edited:
Googling "point in polygon" will lead you to a a number of algorithms. Take your pick.
 
If you are on about a 3D model then you can go to edit poly mode, then vertex, select all the vertices then it will put your move tool or whatever in the centre of all of them, but you may want to change the Z value axis to 0.

If it is aerial imagery, you could simply enter in the top/bottom left and top/bottom right co-ordinates, this will place the imagery exactly where it needs to be, then use alpha channels to remove the areas you want to get rid of
 
Back
Top