Check of point inside/outside polygon
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jan 11 09:05:41 PST 2017
On Tuesday, 26 July 2016 at 13:32:00 UTC, Suliman wrote:
> Ideally I need algorithm that can return bool if one polygon
> overlapped/intersected by another. But I do not know math.
>
> After some googling I found topic on SO[1] about point
> inside/outside polygon. It's not directly what I need, but as
> temporal solution would be enough.
>
> Maybe somebody already wrote this algorithm in D. Could you
> share it plz.
>
> I tried to translate algorithm in D, but I do not understand
> some things. For example:
>
> public static bool PointInPolygon(LatLong p, List<LatLong>
> poly) // Ok we are getting `p` - looking point, and `poly` --
> our polygon. But what format it should have? WKT? Something
> else?
>
> poly.Add(new LatLong { Lat = poly[0].Lat, Lon = poly[0].Lon });
> // Why we add Lat and Long to poly? And again what it's format?
>
> All other code look work in D to.
>
>
> [1]
> http://stackoverflow.com/questions/924171/geo-fencing-point-inside-outside-polygon/6786279#6786279
How could I miss this. Working:
https://github.com/BBasile/kheops/blob/master/src/kheops/helpers/polygons.d#L130
It works fine. I've tested it after translation and rotation:
Okay.
More information about the Digitalmars-d-learn
mailing list