dimforge / parry

2D and 3D collision-detection library for Rust.
https://parry.rs
Apache License 2.0
567 stars 100 forks source link

`corner_direction` wrongly returns `Orientation::None` #99

Open hannobraun opened 1 year ago

hannobraun commented 1 year ago

I'm getting a wrong result from corner_direction for a specific set of points. The following test fails, even though the points are clearly not on a line:

#[test]
fn corner_direction_bug() {
    let p1 = Point::from([-0.5, 0.8660254037844387]);
    let p2 = Point::from([1., 1.7320508075688772]);
    let p3 = Point::from([-2., 0.]);

    assert_ne!(corner_direction(&p1, &p2, &p3), Orientation::None);
}

I don't know what is special about these values. These just happened to be the points I've seen this issue with in my code base (modulo some light rounding). If I round the longer values (to 0.9 or 1.7), the test no longer fails.