Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

How to detect point on border as insided one. #12

Closed
joonhwan opened this issue Sep 12, 2017 · 2 comments
Closed

How to detect point on border as insided one. #12

joonhwan opened this issue Sep 12, 2017 · 2 comments
Labels

Comments

@joonhwan
Copy link

For a given rect like

(-1, -1), (-1, 1), (1, 1), (1, -1)

the point (0,1) is not detected as inside of polygon.
How to detect it as insid of polygon?

@sromku
Copy link
Owner

sromku commented Sep 12, 2017

The used algorithm here is Ray casting algorithm. If the test point is on the border of the polygon, this algorithm will deliver unpredictable results; i.e. the result may be “inside” or “outside”. In general it depends on ray creation with respect to the coordinate system.

From wiki:
Unfortunately, this method won't work if the point is on the edge of the polygon.

For example, in polygon (-1, -1), (-1, 1), (1, 1), (1, -1):

  • This is outside: (0,1)
  • This is inside: (-1,0)

sromku added a commit that referenced this issue Sep 12, 2017
@sromku
Copy link
Owner

sromku commented Sep 12, 2017

You can see the new added test to showcase this issue. e5717ff

@sromku sromku closed this as completed Sep 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants