I am looking for an algorithm through I can create a geofence and check if a device is entering/leaving the fence. I have looked at point in polygon algorithms (ray casting and winding number) but are there any algorithms which can be applied to circle and any irregular shapes as well? The important constraint is time efficiency.
Thank you.
Here is the c code algorithm that is simple to understand:
http://alienryderflex.com/polygon/
Well circles are pretty easy (at least if you are assuming a locally flat surface) - just absolute distance from a point.
The normal way if you need speed is a cascade where you check a circle first, or a square around the point, then a convex polygon, then a more detailed polygon if necessary.
How are you defining the irregular shape - if it's not a polygon?
ps see How to test if a point is inside of a convex polygon in 2D integer coordinates?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With