Coder Social home page Coder Social logo

Comments (6)

seangransee avatar seangransee commented on June 21, 2024 1

Sure! I'll try to take care of it sometime this week.

from ruby-geometry.

seangransee avatar seangransee commented on June 21, 2024 1

PR created in #17. It's not perfect yet, but it's a starting point.

from ruby-geometry.

DanielVartanov avatar DanielVartanov commented on June 21, 2024

Thanks for reporting a very interesting bug. I'll investigate what's happening there.

from ruby-geometry.

seangransee avatar seangransee commented on June 21, 2024

Yes, it appears that Point.contains? is nondeterministic. Here's another example:

point = Geometry::Point.new(509, 553)

polygon = Geometry::Polygon.new([
  Geometry::Point.new(297, 581),
  Geometry::Point.new(464, 414),
  Geometry::Point.new(545, 495),
  Geometry::Point.new(383, 662)
])

results = Array.new(10000).map do
  polygon.contains?(point)
end

puts "contains? returned true #{results.count(true)} times"
puts "contains? returned false #{results.count(false)} times"

Running this prints the following output for me:

contains? returned true 515 times
contains? returned false 9485 times

I suspect this has something to do with the randomness introduced in point_in_polygon.rb line 54.

In my application, I've monkey-patched the Point.contains? method with this algorithm: PNPOLY - Point Inclusion in Polygon Test.

from ruby-geometry.

DanielVartanov avatar DanielVartanov commented on June 21, 2024

Hey @seangransee, can you please form a PR with your patch? This problem is indeed very serious.

from ruby-geometry.

DanielVartanov avatar DanielVartanov commented on June 21, 2024

Thanks in advance!

from ruby-geometry.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.