Skip to content

Commit

Permalink
Fixes point not detected in polygon (#46)
Browse files Browse the repository at this point in the history
* Fixes point not detected in polygon

* Added test and increased epsilon again
  • Loading branch information
MJohnson459 committed Jan 17, 2024
1 parent 1a0a93e commit 672e101
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/helpers.rs
Expand Up @@ -5,7 +5,7 @@ use tracing::instrument;

use crate::instance::EdgeSide;

const EPSILON: f32 = 1e-2;
const EPSILON: f32 = 1e-4;

pub(crate) trait Vec2Helper {
fn side(self, edge: (Vec2, Vec2)) -> EdgeSide;
Expand Down Expand Up @@ -224,6 +224,23 @@ mod tests {
),
EdgeSide::Edge
);

// Test epsilon value is large enough
assert_eq!(
Vec2Helper::side(
Vec2::new(5.585231282, 5.3880110045),
(Vec2::new(9.56, 7.42), Vec2::new(1.54, 3.32))
),
EdgeSide::Edge
);
// Test epsilon value is small enough
assert_ne!(
Vec2Helper::side(
Vec2::new(1.8266357, 1.2239377),
(Vec2::new(1.775, 1.275), Vec2::new(1.775, 1.175))
),
EdgeSide::Edge
);
}

#[test]
Expand Down

0 comments on commit 672e101

Please sign in to comment.