shape: Fix bend-seg intersection

By making zero-length bends non-intersectable.
This commit is contained in:
Mikolaj Wielgus 2023-10-15 01:13:33 +00:00
parent 4ec32c97ba
commit ce72a2ba4b
2 changed files with 7 additions and 5 deletions

View File

@ -194,10 +194,12 @@ pub fn intersect_circle_segment(circle: &Circle, segment: &Line) -> Vec<Point> {
pub fn between_vectors(p: Point, from: Point, to: Point) -> bool { pub fn between_vectors(p: Point, from: Point, to: Point) -> bool {
let cross = cross_product(from, to); let cross = cross_product(from, to);
if cross >= 0. { if cross > 0.0 {
cross_product(from, p) >= 0. && cross_product(p, to) >= 0. cross_product(from, p) >= 0.0 && cross_product(p, to) >= 0.0
} else if cross < 0.0 {
cross_product(from, p) >= 0.0 || cross_product(p, to) >= 0.0
} else { } else {
cross_product(from, p) >= 0. || cross_product(p, to) >= 0. false
} }
} }

View File

@ -136,7 +136,7 @@ impl Shape {
Shape::Dot(..) => unreachable!(), Shape::Dot(..) => unreachable!(),
Shape::Seg(other) => seg.polygon().intersects(&other.polygon()), Shape::Seg(other) => seg.polygon().intersects(&other.polygon()),
Shape::Bend(other) => { Shape::Bend(other) => {
/*for segment in seg.polygon().exterior().lines() { for segment in seg.polygon().exterior().lines() {
let inner_circle = other.inner_circle(); let inner_circle = other.inner_circle();
let outer_circle = other.outer_circle(); let outer_circle = other.outer_circle();
@ -151,7 +151,7 @@ impl Shape {
return true; return true;
} }
} }
}*/ }
false false
} }