From 94e67d4caf76674e1f8426e8517aef3d27c68fa3 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:53:02 -0400 Subject: [PATCH] Kernel loft test: the square-to-circle loft has the oracle's exact ruled volume, without printing Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tests.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index 641f5aad6..80e913288 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -726,9 +726,11 @@ fn loft_and_sweep() { let sq = Loop2::polygon(&[Vec2::new(-20.0, -20.0), Vec2::new(20.0, -20.0), Vec2::new(20.0, 20.0), Vec2::new(-20.0, 20.0)]); let top = Plane::XY.offset(40.0); let l = loft(&[(Plane::XY, sq), (top, Loop2::circle(Vec2::ZERO, 10.0))]).unwrap(); - let m = measure(&l).unwrap(); - println!("loft volume {} faces {:?}", m.volume, m.merged); - assert!(m.volume > 314.0 * 40.0 && m.volume < 1600.0 * 40.0); + // Ruled, each side on the rational quarter of the circle between its corners' directions: the + // section at t has area (1 − t)² A_S + t² A_C + t(1 − t) M, M = ½∮(S × C' + C × S'), so + // V = h (A_S/3 + A_C/3 + M/6) = 35080.725 (M = 1433.790 by quadrature; tests/oracle/17-loft). + let v = measure(&l).unwrap().volume; + assert!(rel(v, 35080.725116) < 1e-6, "{v}"); // A tube: up 30, quarter bend of radius 20, across 30. let disc = Region2 { outer: Loop2::circle(Vec2::ZERO, 3.0), holes: vec![] }; let path = [ @@ -742,9 +744,6 @@ fn loft_and_sweep() { PathSeg::Line { a: Vec3::new(20.0, 0.0, 50.0), b: Vec3::new(50.0, 0.0, 50.0) }, ]; let t = sweep(&Plane::XY, &disc, &path).unwrap(); - for tol in [0.1, 0.01, 0.003, 0.001] { - println!("tube tess {tol}: {}", t.mesh(&crate::MeshTolerance::chord(tol)).unwrap().measure().volume); - } let area = PI * 9.0; let expect = area * (30.0 + 30.0 + 20.0 * std::f64::consts::FRAC_PI_2); assert!(rel(measure(&t).unwrap().volume, expect) < 1e-3, "{} vs {expect}", measure(&t).unwrap().volume);