M4: the radius tests pick each arc by its middle too (opposite corners share both ends, #2334)

This commit is contained in:
ljkx committed 2026-11-13 17:34:37 +01:00
1 parent 8336043787
commit e62b140845
1 file changed
+4 -3
+4 -3
View File
@@ -45,9 +45,10 @@ fn assert_arcs(path: &BezPath, want: &[(Point, Point, Point, f64)], why: &str) {
let (a, b) = (toward(prev), toward(next));
let center = a + (b - corner);
let mid = center + (corner - center) / (corner - center).hypot() * t;
let arc = got.iter().find(|c| (near(c.p0, a) && near(c.p3, b)) || (near(c.p0, b) && near(c.p3, a)));
let Some(arc) = arc else { panic!("{why}: no arc from {a:?} to {b:?} in {got:?}") };
assert!(near(arc.eval(0.5), mid), "{why}: the arc at {corner:?} passes {:?}, not {mid:?}", arc.eval(0.5));
// Two arcs can share both ends (opposite corners of a square), so the middle picks one.
let ends = |c: &&CubicBez| (near(c.p0, a) && near(c.p3, b)) || (near(c.p0, b) && near(c.p3, a));
let passing: Vec<Point> = got.iter().filter(ends).map(|c| c.eval(0.5)).collect();
assert!(passing.iter().any(|&m| near(m, mid)), "{why}: no arc at {corner:?} from {a:?} to {b:?} through {mid:?}; arcs between them pass {passing:?}");
}
}