-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Some boundary points return false] contains - Polygon #66
Comments
I'm doubting this is repository is actively monitored by maintainers. However the following code results in this output: package main
import (
"fmt"
geo "github.com/kellydunn/golang-geo"
)
func main() {
poly := []*geo.Point{
geo.NewPoint(0, 0), geo.NewPoint(0, 1), geo.NewPoint(1, 1), geo.NewPoint(1, 0),
}
gon := geo.NewPolygon(poly)
fmt.Println("x:0\ty:0\t", "Expecting: true\t", "Got:", gon.Contains(geo.NewPoint(0, 0)))
fmt.Println("x:0.5\ty:0\t", "Expecting: true\t", "Got:", gon.Contains(geo.NewPoint(0.5, 0)))
fmt.Println("x:0.5\ty:0.7\t", "Expecting: true\t", "Got:", gon.Contains(geo.NewPoint(0.5, 0.7)))
fmt.Println("x:2\ty:8\t", "Expecting: false\t", "Got:", gon.Contains(geo.NewPoint(2, 8)))
} Output: x:0 y:0 Expecting: true Got: false
x:0.5 y:0 Expecting: true Got: true
x:0.5 y:0.7 Expecting: true Got: true
x:2 y:8 Expecting: false Got: false Does anyone have an idea how this could be fixed? Which algorithm is used? Raycasting or Gauß-Jordan or ...? I made little repo to just run and go. |
👋 howdy!
yes life keeps me busy and I haven't had time to maintain this as much as I would like, but! I welcome any PRs if you'd like to contribute upstream! It's been a while since I've looked at the Polygon code, but I believe it's historically used Raycasting: https://github.com/kellydunn/golang-geo/blob/master/polygon.go#L65 |
I didn't change anything on the raycasting algorithm but #71 should be a viable workaround. |
Some points on boundary line or on polygon vertices return false in contains- Polygon.
For example ,
polygon- (0,0), (5, 0), (5, 5 ) , (0, 5) returns false for point (0,0)
The text was updated successfully, but these errors were encountered: