golang / geo

S2 geometry library in Go
Apache License 2.0
1.68k stars 182 forks source link

Polygon Intetersection didn't work for triangle and rectangle #50

Closed outsidebedisdoor closed 5 years ago

outsidebedisdoor commented 5 years ago

So I use S2.Polygon Intersects methods.

My points as a triangle and another rectangle (when drawing) have no intersection. However, the intersect methods will return true.

I put all the points inside of s2.Point and construct loop using list of s2.point and construct polygon using list of loop. Could some one tell me if I use them wrong or if the algorithm has some problems.

rsned commented 5 years ago

Can you paste an example of the code you are using to construct the two shapes?

On Tue, Apr 30, 2019 at 3:37 PM Yanhe Chen notifications@github.com wrote:

So I use S2.Polygon Intersects methods.

My points as a triangle and another rectangle (when drawing) have no intersection. However, the intersect methods will return true.

I put all the points inside of s2.Point and construct loop using list of s2.point and construct polygon using list of loop. Could some one tell me if I use them wrong or if the algorithm has some problems.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/golang/geo/issues/50, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBHGBAEO6ZS4H3KLLBPNN3PTDCZNANCNFSM4HJQVUUQ .

outsidebedisdoor commented 5 years ago

NVM I found out that I have to read the point using

s2.PointFromLatLng(s2.LatLng{s1.Angle(PointLatitude), s1.Angle(PointLongitude)})

and then it works. Thanks