Giter VIP home page Giter VIP logo

Comments (4)

rmanoka avatar rmanoka commented on June 19, 2024 1

Yes, generally, floating-point numbers has some caveats when converting between display and internal representation.

For instance, 0.1_f64 + 0.2 == 0.3 evaluates to false. This is because, 0.1 is not representible in f64 (or f32), and it's approximated. Now, the degree of this approximation depends on the float type, and in your input I believe the extra point is approximated to fall outside the "true conv hull" when using f32.

If you want to use fixed point/precision, please scale and convert to integers and run the hull (the crate supports hull on i32 or i64 points).

from geo.

rmanoka avatar rmanoka commented on June 19, 2024

Can you try with f64 precision? The points may be too large for f32 to correctly work. You can also try subtracting out the first point, before calling the algo to see if that fixes it.

from geo.

YikChingTsui avatar YikChingTsui commented on June 19, 2024

Thanks for the suggestion, f64 works correctly. Interestingly, 32-bit precision still fails even after subtracting the points so that the leftmost point is at the origin. Not the first time I've encountered floating point issues. Hopefully I won't get an edge case where 64-bit fails too, otherwise I could consider a rational/fraction type instead of floats

from geo.

rmanoka avatar rmanoka commented on June 19, 2024

Closing; the output is correct for the given input (and data type).

from geo.

Related Issues (20)

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.