Skip to content
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

incircle results in NaN result #19

Open
frewsxcv opened this issue Nov 27, 2020 · 1 comment
Open

incircle results in NaN result #19

frewsxcv opened this issue Nov 27, 2020 · 1 comment

Comments

@frewsxcv
Copy link
Member

Is this expected? Does the C version do this?

Found via #18

let data = [
    (
        0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000602151646108571f64,
        -517539169279288000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0f64,
    ),
    (
        0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008335571366403185f64,
        0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000569f64,
    ),
    (
        0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008309872195179385f64,
        0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008309872194912985f64,
    ),
    (
        -24214045710673702000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0f64,
        0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008309872195179618f64,
    ),
];

let pa = robust::Coord { x: data[0].0, y: data[0].1 };
let pb = robust::Coord { x: data[1].0, y: data[1].1 };
let pc = robust::Coord { x: data[2].0, y: data[2].1 };
let pd = robust::Coord { x: data[3].0, y: data[3].1 };

let result = robust::incircle(pa, pb, pc, pd);

assert!(result.is_finite());
thread '<unnamed>' panicked at 'assertion failed: result.is_finite()', fuzz_targets/incircle.rs:13:5
@tinko92
Copy link
Contributor

tinko92 commented May 22, 2023

The C version does this and it is (imho) not unexpected because Shewchuk's algorithms only handle round-off errors, not overflow/underflow in intermediate results. The test for the correctness of the approximate result (

if det > errbound || -det > errbound {
) can succeed even if it is incorrect due to underflow and none of the exact computations (two_{sum, product}, expansion_sum, etc.) will handle overflow or underflow well.

Covering such inputs would require non-trivial changes in the implementation. For the tests of the approximate results there would be changes needed to cover underflow (such as in https://doi.org/10.1007/s10543-015-0574-9 or https://doi.org/10.1007/s10543-023-00975-x) but more problematically, for the exact computations an alternative would be required with extended exponent range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants