From b1a28df0ba56cdc721c6296c3533c29244eceaba Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:15:03 -0400 Subject: [PATCH] Wave 495/509: Kernel tests: variable rounds graded by the union of their balls, the removed volume to 1e-4 of itself (and 3 more) 4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 01e2e939e jyviko: Variable rounds: graded by the union of their balls (their envelope), not the balls' great circles - 7bba3092c jyviko: Kernel tests: variable rounds graded by the union of their balls, the removed volume to 1e-4 of itself - 0b1cc8a8c jyviko: Kernel tests: a spline radius whose balls fold over one another at its peak is refused - 1745e5c38 jyviko: Kernel rig: the variable round on its cone passes (the round is the balls' envelope) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- crates/kernel/src/blend_smlib.rs | 9 +- crates/kernel/src/blend_variable.rs | 187 ++++++++++++++---- crates/smlib/src/ops_tests.rs | 38 ++-- tests/KNOWN_FAILING_TESTS | 2 + tests/kernel-cases/fillets/KNOWN_FAILING | 1 - .../005-variable-r5-to-r1/expected.json | 4 +- .../006-variable-r5-to-zero/expected.json | 4 +- .../007-variable-r5-to-1e-3/expected.json | 4 +- .../expected.json | 6 +- 9 files changed, 184 insertions(+), 71 deletions(-) diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs index 49030caa0..88e209246 100644 --- a/crates/kernel/src/blend_smlib.rs +++ b/crates/kernel/src/blend_smlib.rs @@ -624,14 +624,15 @@ mod tests { #[test] fn a_linear_radius_runs_from_the_start_end() { - // 3 at x = 0 to 1 at x = 20: (1 - pi/4) L (r0^2 + r0 r1 + r1^2) / 3 taken away, from - // either end given as the start with the law reversed. + // 3 at x = 0 to 1 at x = 20: the balls' union, a cone, takes 18.5377834 (their great + // circles, (1 - pi/4) L (r0^2 + r0 r1 + r1^2) / 3, would take 18.5988), from either end + // given as the start with the law reversed. let b = cube(); let at = Vec3::new(10.0, 20.0, 20.0); let law = RadiusSpline { degree: 1, knots: vec![0.0, 0.0, 1.0, 1.0], radii: vec![3.0, 1.0] }; let r = imp::variable(&b, at, Vec3::new(0.0, 20.0, 20.0), &law).unwrap(); - let want = 8000.0 - QUARTER * 20.0 * 13.0 / 3.0; - assert!((volume(&r) - want).abs() < 0.05, "{}", volume(&r)); + let want = 8000.0 - 18.5377834; + assert!((volume(&r) - want).abs() < 0.01, "{}", volume(&r)); let back = imp::variable(&b, at, Vec3::new(20.0, 20.0, 20.0), &law.reversed()).unwrap(); assert!((volume(&back) - volume(&r)).abs() < 1e-6 * 8000.0); } diff --git a/crates/kernel/src/blend_variable.rs b/crates/kernel/src/blend_variable.rs index 03f41ef10..381f95abd 100644 --- a/crates/kernel/src/blend_variable.rs +++ b/crates/kernel/src/blend_variable.rs @@ -545,16 +545,17 @@ mod tests { assert_eq!((less.eval(0.0), less.eval(1.0)), (2.0, 3.0)); } - /// The material a variable fillet removes from a right-angled edge of length L, radius - /// running r0 → r1: ∫ (1 − π/4) r(t)² dt = (1 − π/4) L (r0² + r0 r1 + r1²) / 3. + /// The material a variable fillet removes from a right-angled edge, radius running r0 → r1: + /// its balls' union (`removed_by_balls`; the balls' great circles, (1 − π/4) L (r0² + r0 r1 + + /// r1²) / 3, take more), to 1e-4 of itself. #[test] fn variable_radius_on_a_box_edge() { let b = box_solid(Vec3::ZERO, Vec3::new(10.0, 20.0, 30.0)).unwrap(); // The edge along y at x = 10, z = 30; radius 2 at y = 0, 5 at y = 20. let f = fillet_variable(&b, Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 0.0, 30.0), 2.0, 5.0).unwrap(); - let removed = (1.0 - std::f64::consts::FRAC_PI_4) * 20.0 * (4.0 + 10.0 + 25.0) / 3.0; + let removed = removed_by_balls(20.0, &|u| 2.0 + 3.0 * u, &open, &[]); let v = measure(&f).unwrap().volume; - assert!(rel(v, 6000.0 - removed) < 1e-4, "{v} vs {}", 6000.0 - removed); + assert!(rel(6000.0 - v, removed) < 1e-4, "{} removed vs {removed}", 6000.0 - v); // Started from the other end: the same solid. let h = fillet_variable(&b, Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 20.0, 30.0), 5.0, 2.0).unwrap(); assert!(rel(measure(&h).unwrap().volume, v) < 1e-9); @@ -564,37 +565,42 @@ mod tests { assert!(rel(measure(&g).unwrap().volume, measure(&k).unwrap().volume) < 1e-6); // Wider than the faces: past r = 10 the contact on the top leaves it across its far edge // x = 0 (past r = 30 the one on the side across its bottom), cliffs. The round is built as - // if the faces went on, and what it removes is cut from the box: at each y the section of - // the r x r square at the edge less the quarter disc about (10 - r, 30 - r), inside - // [0, 10] x [0, 30], in closed form (a, b from the disc's centre: a, b in [0, r], - // a^2 + b^2 >= r^2, a >= r - 10, b >= r - 30), integrated along y by Gauss-Legendre - // between the kinks at r = 10 and 30: 2453.81232061 removed, 3546.18767939 left (to 1e-4, - // as the variable rounds above). + // if the faces went on, and what it removes is cut from the box: the balls' union inside + // the box's section, 10 along the top and 30 down the side (the great circles' would take + // 2453.81, near twice as much). let w = fillet_variable(&b, Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 0.0, 30.0), 2.0, 50.0).unwrap(); + let removed_w = removed_by_balls(20.0, &|u| 2.0 + 48.0 * u, &slab, &[20.0 * 8.0 / 48.0, 20.0 * 28.0 / 48.0]); let vw = measure(&w).unwrap().volume; - assert!(rel(vw, 3546.1876793935) < 1e-4, "{vw} vs 3546.1876793935"); + assert!(rel(6000.0 - vw, removed_w) < 1e-4, "{} removed vs {removed_w}", 6000.0 - vw); } - /// A radius through a middle point: straight pieces (exact: each piece removes - /// (1 − π/4) L (a² + ab + b²) / 3), and smooth (the removed volume integrates the law). + /// A radius through a middle point, straight pieces 2 → 4 → 2: a corner in the law, where the + /// ball there shows between its two sides' touch circles; the balls' union takes 39.541034 + /// (the halves' great circles would take 40.0590). + #[test] + fn variable_radius_with_a_corner_through_a_middle_point() { + let b = box_solid(Vec3::ZERO, Vec3::new(10.0, 20.0, 30.0)).unwrap(); + let (at, start) = (Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 0.0, 30.0)); + let f = fillet_variable_points(&b, at, start, &[(0.0, 2.0), (0.5, 4.0), (1.0, 2.0)], false).unwrap(); + let removed = removed_by_balls(20.0, &|u| 4.0 - 4.0 * (u - 0.5).abs(), &open, &[10.0]); + assert!((removed - 39.541034).abs() < 1e-5, "{removed}"); + let v = measure(&f).unwrap().volume; + assert!(rel(6000.0 - v, removed) < 1e-4, "{} removed vs {removed}", 6000.0 - v); + assert_eq!(f.unmeshed_faces(), 0); + } + + /// A radius through a middle point, smooth: the removed volume is the balls' union. #[test] fn variable_radius_through_a_middle_point() { let b = box_solid(Vec3::ZERO, Vec3::new(10.0, 20.0, 30.0)).unwrap(); let (at, start) = (Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 0.0, 30.0)); - let k = 1.0 - std::f64::consts::FRAC_PI_4; let pts = [(0.0, 2.0), (0.5, 4.0), (1.0, 2.0)]; - let f = fillet_variable_points(&b, at, start, &pts, false).unwrap(); - let removed = 2.0 * k * 10.0 * (4.0 + 8.0 + 16.0) / 3.0; - let v = measure(&f).unwrap().volume; - assert!(rel(v, 6000.0 - removed) < 1e-4, "{v} vs {}", 6000.0 - removed); - assert_eq!(f.unmeshed_faces(), 0); let s = fillet_variable_points(&b, at, start, &pts, true).unwrap(); let law = RadiusSpline::through(&pts, true); - let n = 20000; - let integral: f64 = (0..n).map(|i| law.eval((i as f64 + 0.5) / n as f64).powi(2)).sum::() / n as f64 * 20.0; assert!((law.eval(0.5) - 4.0).abs() < 1e-12 && (law.eval(0.0) - 2.0).abs() < 1e-12); + let removed = removed(&law, 20.0); let v = measure(&s).unwrap().volume; - assert!(rel(v, 6000.0 - k * integral) < 1e-4, "{v} vs {}", 6000.0 - k * integral); + assert!(rel(6000.0 - v, removed) < 1e-4, "{} removed vs {removed}", 6000.0 - v); // Unsorted, from the other end: the same. let r = fillet_variable_points(&b, at, Vec3::new(10.0, 20.0, 30.0), &[(1.0, 2.0), (0.0, 2.0), (0.5, 4.0)], true).unwrap(); assert!(rel(measure(&r).unwrap().volume, v) < 1e-9); @@ -606,16 +612,18 @@ mod tests { } /// The radius running down to zero at one end: the blend closes to the corner, a three-sided - /// face, and the end face there is untouched. Removed (1 − π/4) L r0² / 3 when linear. + /// face, and the end face there is untouched. Removed: the balls' union (a cone to its apex + /// when linear, 22.594877; the great circles' (1 − π/4) L r0² / 3 would take 22.8945). #[test] fn variable_radius_down_to_zero_at_one_end() { let b = box_solid(Vec3::ZERO, Vec3::new(10.0, 20.0, 30.0)).unwrap(); let (at, start, end) = (Vec3::new(10.0, 10.0, 30.0), Vec3::new(10.0, 0.0, 30.0), Vec3::new(10.0, 20.0, 30.0)); - let k = 1.0 - std::f64::consts::FRAC_PI_4; + let cone = removed_by_balls(20.0, &|u| 4.0 - 4.0 * u, &open, &[]); + assert!((cone - 22.594877).abs() < 1e-5, "{cone}"); for (r0, r1) in [(4.0, 0.0), (0.0, 4.0)] { let f = fillet_variable(&b, at, start, r0, r1).unwrap(); let v = measure(&f).unwrap().volume; - assert!(rel(v, 6000.0 - k * 20.0 * 16.0 / 3.0) < 1e-4, "{r0} → {r1}: {v}"); + assert!(rel(6000.0 - v, cone) < 1e-4, "{r0} → {r1}: {} removed vs {cone}", 6000.0 - v); assert_eq!(f.unmeshed_faces(), 0); let (faces, vertices) = faces_and_vertices(&f); assert_eq!(faces.len(), 7); @@ -628,10 +636,9 @@ mod tests { let pts = [(0.0, 3.0), (0.5, 4.0), (1.0, 0.0)]; let s = fillet_variable_points(&b, at, start, &pts, true).unwrap(); let law = RadiusSpline::through(&pts, true); - let n = 20000; - let integral: f64 = (0..n).map(|i| law.eval((i as f64 + 0.5) / n as f64).powi(2)).sum::() / n as f64 * 20.0; + let removed = removed(&law, 20.0); let v = measure(&s).unwrap().volume; - assert!(rel(v, 6000.0 - k * integral) < 1e-4, "{v} vs {}", 6000.0 - k * integral); + assert!(rel(6000.0 - v, removed) < 1e-4, "{} removed vs {removed}", 6000.0 - v); // Zero at both ends, zero in the middle, a smooth radius dipping below zero, or a radius // too small to build: refused. assert!(fillet_variable(&b, at, start, 0.0, 0.0).is_err()); @@ -664,11 +671,113 @@ mod tests { crate::boolean(&plate, &wall, crate::BoolOp::Union).unwrap().unwrap() } - /// The material a right-angled blend with the radius `law` removes along an edge of length L: - /// ∫ (1 − π/4) r² over the edge. + /// Simpson's rule for `f` on [a, b] in `n` (even) panels. + fn simpson(f: impl Fn(f64) -> f64, a: f64, b: f64, n: usize) -> f64 { + let h = (b - a) / n as f64; + (0..=n) + .map(|i| { + f(a + i as f64 * h) + * if i == 0 || i == n { + 1.0 + } else if i % 2 == 1 { + 4.0 + } else { + 2.0 + } + }) + .sum::() + * h + / 3.0 + } + + /// The material a variable round removes from a right-angled edge of length `len`: what no + /// ball reaches, the round being the union of its balls (their envelope; each ball touches it + /// along the circle square to the line of centres, not its great circle, as the radius + /// varies). The ball at s along the edge has radius `law(s / len)` (the law going on past the + /// ends along its end slopes) and its centre that far from both faces. In each plane square + /// to the edge at x, the ray from the edge at angle θ from the first face meets the union + /// first at the least entry over the balls, and the corner up to there is taken, as far as + /// `room(x, θ)` (the body's section along the ray; ∞ where it does not end): ∫ ρ²/2 dθ, + /// integrated over x, both by Simpson's rule, split at `kinks` (where the law turns). + pub(crate) fn removed_by_balls(len: f64, law: &dyn Fn(f64) -> f64, room: &dyn Fn(f64, f64) -> f64, kinks: &[f64]) -> f64 { + let h = 1e-7; + let (k0, k1) = ((law(h) - law(0.0)) / (h * len), (law(1.0) - law(1.0 - h)) / (h * len)); + let r = |s: f64| { + if s < 0.0 { + law(0.0) + k0 * s + } else if s > len { + law(1.0) + k1 * (s - len) + } else { + law(s / len) + } + }; + let big = (0..=1000).map(|i| law(i as f64 / 1000.0)).fold(0.0f64, f64::max); + let entry = |x: f64, c: f64, sn: f64, s: f64| { + let rr = r(s); + let p = rr * (c + sn); + let disc = p * p - (x - s) * (x - s) - rr * rr; + if rr > 0.0 && disc >= 0.0 { p - disc.sqrt() } else { f64::INFINITY } + }; + let rho = |x: f64, t: f64| { + let (c, sn) = (t.cos(), t.sin()); + let (lo, hi, scan) = (x - 1.5 * big, x + 1.5 * big, 400); + let step = (hi - lo) / scan as f64; + let (mut best, mut at) = (f64::INFINITY, x); + for i in 0..=scan { + let s = lo + i as f64 * step; + let e = entry(x, c, sn, s); + if e < best { + (best, at) = (e, s); + } + } + let (mut a, mut b, g) = (at - step, at + step, (5f64.sqrt() - 1.0) / 2.0); + for _ in 0..80 { + let (m1, m2) = (b - g * (b - a), a + g * (b - a)); + if entry(x, c, sn, m1) < entry(x, c, sn, m2) { + b = m2; + } else { + a = m1; + } + } + best.min(entry(x, c, sn, 0.5 * (a + b))) + }; + // The rays meet the union tangentially at the faces (ρ goes as the root of the angle + // there): θ = π/4 (1 − cos(π q)) makes the integrand smooth in q. + let area = |x: f64| { + let q = std::f64::consts::PI; + simpson( + |u: f64| { + let t = q / 4.0 * (1.0 - (q * u).cos()); + let p = rho(x, t).min(room(x, t)); + let p = if p.is_finite() { p } else { 0.0 }; + 0.5 * p * p * q * q / 4.0 * (q * u).sin() + }, + 0.0, + 1.0, + 128, + ) + }; + let mut ends = vec![0.0]; + ends.extend(kinks.iter().copied().filter(|k| *k > 0.0 && *k < len)); + ends.push(len); + ends.windows(2).map(|w| simpson(area, w[0], w[1], 2 * ((64.0 * (w[1] - w[0]) / len).ceil() as usize).max(1))).sum() + } + + /// No end to the body's section: the faces go on past the round. + fn open(_x: f64, _t: f64) -> f64 { + f64::INFINITY + } + + /// The 10 x 20 x 30 box's section about its edge x = 10, z = 30: 10 along the top, 30 down + /// the side. + fn slab(_x: f64, t: f64) -> f64 { + (10.0 / t.cos().max(1e-300)).min(30.0 / t.sin().max(1e-300)) + } + + /// The material a right-angled blend with the radius `law` removes along an edge of length L + /// where the faces go on past it: the union of its balls. fn removed(law: &RadiusSpline, len: f64) -> f64 { - let n = 20000; - (1.0 - std::f64::consts::FRAC_PI_4) * (0..n).map(|i| law.eval((i as f64 + 0.5) / n as f64).powi(2)).sum::() / n as f64 * len + removed_by_balls(len, &|u| law.eval(u), &open, &[]) } /// The volume of a fine tessellation: at a blend closed to a point `measure` takes a @@ -749,15 +858,13 @@ mod tests { assert!(fillet_variable_spline(&b, at, start, &unclamped).is_err()); let dips = RadiusSpline { radii: vec![2.0, 0.0, 0.0, 3.0, 2.0], ..law.clone() }; assert!(fillet_variable_spline(&b, at, start, &dips).is_err()); - // A middle radius beyond the faces (up to 21.25 on the top 10 wide): the contact on the top - // leaves it across its far edge, a cliff, and the round is cut as if the top went on: at - // each y the r x r square at the edge less the quarter disc about (10 - r, 30 - r), inside - // [0, 10] x [0, 30], in closed form, integrated along y (Gauss-Legendre, split at the - // knot and where r crosses 10): 726.5334566720 removed. + // A middle radius up to 21.25 (on the top 10 wide), rising and falling so fast that the + // balls' envelope folds over itself at the peak: for the balls' family + // F(y, p) = |p - c(y)|² - r(y)² the touch arc there has F_yy down to -8.88 (where the touch + // circles move back along the edge). Refused, never built folded (the balls' great + // circles, which never fold, built it to 726.53 removed against the union's 332.2). let big = RadiusSpline { radii: vec![2.0, 2.0, 40.0, 3.0, 2.0], ..law }; - let wide = fillet_variable_spline(&b, at, start, &big).unwrap(); - let vw = fine_volume(&wide); - assert!(rel(vw, 6000.0 - 726.5334566720) < 1e-4, "{vw} vs {}", 6000.0 - 726.5334566720); + assert!(matches!(fillet_variable_spline(&b, at, start, &big), Err(KernelError::TooLarge(_)))); } #[test] diff --git a/crates/smlib/src/ops_tests.rs b/crates/smlib/src/ops_tests.rs index 85e3ab4b6..f069e6148 100644 --- a/crates/smlib/src/ops_tests.rs +++ b/crates/smlib/src/ops_tests.rs @@ -286,37 +286,30 @@ fn blends_take_a_size_per_edge() { assert!(c.blend(Blend::Round, &tops, &[2.0], 0.1).is_err()); } -/// A radius running linearly from 3 to 1 along a cube edge: (1 - pi/4) L (r0² + r0 r1 + r1²) / 3 -/// taken away, whichever end is the start. +/// A variable round is the union of its balls: in each plane square to the edge, the corner cut off +/// by rays from it, each meeting the union first at the least entry over the balls, integrated +/// along the edge (a linear law's balls envelop a cone). The balls' great circles, (1 - pi/4) r² +/// per unit length, take more: 18.5988 for 3 -> 1, 39.0796 for 4, 1, 4 and 22.8945 for 4 -> 0. +/// On the 20 cube's edge y = z = 20, 3 -> 1 takes 18.5377834 whichever end is the start. #[test] fn a_variable_round_follows_its_law() { let c = cube(20.0); - let q = 1.0 - std::f64::consts::FRAC_PI_4; let knots = [0.0, 0.0, 1.0, 1.0]; let r = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &knots, &[3.0, 1.0]).unwrap(); shot(&r, "variable-3-1"); - assert_close(volume(&r), 8000.0 - q * 20.0 * 13.0 / 3.0, 1e-5, "linear law"); + assert_close(volume(&r), 8000.0 - 18.5377834, 1e-5, "linear law"); let back = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [20.0, 20.0, 20.0], 1, &knots, &[1.0, 3.0]).unwrap(); assert_close(volume(&back), volume(&r), 1e-7, "reversed"); assert!(c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.5, 1.0, 1.0], &[3.0, 1.0]).is_err()); assert!(matches!(c.fillet_variable([90.0, 90.0, 90.0], 0.1, [0.0; 3], 1, &knots, &[3.0, 1.0]), Err(Error::NoMatch { .. }))); - // A quadratic law with control radii 4, 1, 4: r(t) = 4(1 − t)² + 2t(1 − t) + 4t². - let law = |t: f64| 4.0 * (1.0 - t).powi(2) + 2.0 * t * (1.0 - t) + 4.0 * t * t; - let n = 4000; - let r2 = (0..n).map(|i| law((i as f64 + 0.5) / n as f64).powi(2)).sum::() / n as f64; + // A quadratic law with control radii 4, 1, 4, r(t) = 4(1 − t)² + 2t(1 − t) + 4t²: 39.019820. let quad = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 2, &[0.0, 0.0, 0.0, 1.0, 1.0, 1.0], &[4.0, 1.0, 4.0]).unwrap(); shot(&quad, "variable-quadratic"); - assert_close(volume(&quad), 8000.0 - q * 20.0 * r2, 1e-5, "quadratic law"); - // Down to zero at the far end: the round closes to the edge's end point. + assert_close(volume(&quad), 8000.0 - 39.019820, 1e-5, "quadratic law"); + // Down to zero at the far end: the round closes to the edge's end point, 22.594877. let zero = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &knots, &[4.0, 0.0]).unwrap(); shot(&zero, "variable-to-zero"); - assert_close(volume(&zero), 8000.0 - q * 20.0 * 16.0 / 3.0, 1e-5, "down to zero"); - // A law with a corner (4 → 2 → 4, straight on both halves): the round turns at the corner, - // each half taking away (1 - pi/4) (L / 2) (16 + 8 + 4) / 3; the same points joined smoothly - // (C1 cubic pieces, as RadiusSpline::through makes them) are built too. - let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]).unwrap(); - shot(&corner, "variable-corner-4-2-4"); - assert_close(volume(&corner), 8000.0 - q * 20.0 * 28.0 / 3.0, 1e-6, "corner law"); + assert_close(volume(&zero), 8000.0 - 22.594877, 1e-5, "down to zero"); // A law down to zero inside the edge would pinch the round to a point: refused. let pinch = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 0.0, 4.0]); assert!(pinch.is_err(), "a law pinching to zero inside the edge"); @@ -325,6 +318,17 @@ fn a_variable_round_follows_its_law() { shot(&smooth.unwrap(), "variable-smooth-4-2-4"); } +/// A law with a corner (4 → 2 → 4, straight on both halves) on the 20 cube's edge y = z = 20: the +/// union of the balls, where the two halves' rounds cross and each ends, takes 39.542073 (the +/// halves' great circles would take 40.0590). +#[test] +fn a_variable_round_with_a_corner_in_its_law_is_its_balls_union() { + let c = cube(20.0); + let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]).unwrap(); + shot(&corner, "variable-corner-4-2-4"); + assert_close(volume(&corner), 8000.0 - 39.542073, 1e-5, "corner law"); +} + /// Unequal chamfers of a cube's top edge y = 20: 5 back along the face facing `first` most and 2 /// along the other take away a triangle 5 × 2 / 2 along the 20 mm edge, either way round; 5 at /// 30° to the first face is 5 and 5 tan 30°. diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index b6e44f52a..eb820ad5c 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -14,7 +14,9 @@ solidcraft-engine::tests::fillet_fit_taper_closes_to_a_point SMLib fillet status solidcraft-kernel::blend::corner_tests::a_round_ending_in_an_earlier_round_matches_both_together SMLib fillet status 1001 on the round that ends in the earlier one solidcraft-kernel::blend::corner_tests::corner_blends_hold_at_any_scale at 0.01x the arc case's rounds remove 72.783 (scaled back) against 72.713 at 1x (9.6e-4 off, 1e-4 allowed) solidcraft-kernel::blend_corner::tests::issue2422_vertical_after_separate_bottom_rounds SMLib's check refuses the fillet: edge and vertex tolerance 0.97 against the body's 0.01 (#2422) +solidcraft-kernel::blend_variable::tests::variable_radius_with_a_corner_through_a_middle_point the two halves' rounds end on their own touch circles at the law's corner and the ball's sphere between them is not built: 39.8302 removed against 39.5410 solidcraft-kernel::corner_g2::tests::a_long_setback_keeps_the_g2_patch_inside_the_box at set backs 11 to 15 the G2 corner patch bulges 2.6e-6 to 1.33e-3 past the box (the explicit corner is in progress) solidcraft-kernel::corner_g2::tests::curvature_rounds_meet_at_a_g2_corner the explicit G2 corner patch is not yet G2 to the new order-2 section's rounds across the whole seam (the corner step replaces it) solidcraft-kernel::corner_g2::tests::the_box_corner_g2_patch_is_a_closed_solid_curvature_continuous_to_its_neighbours the fitted G2 corner patch bulges 1.7e-5 past the box, which SMLib's exact tight box now sees (the explicit G2 corner builds it inside) solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the arc and tab rounds together remove 9.20067 against 9.20420 (3.8e-4 off, 1e-5 allowed) +solidcraft-smlib::ops::tests::a_variable_round_with_a_corner_in_its_law_is_its_balls_union the two halves' rounds end on their own touch circles at the law's corner, not where they cross: 39.6456 removed against 39.5421 diff --git a/tests/kernel-cases/fillets/KNOWN_FAILING b/tests/kernel-cases/fillets/KNOWN_FAILING index 41e80e66d..fa0bf839b 100644 --- a/tests/kernel-cases/fillets/KNOWN_FAILING +++ b/tests/kernel-cases/fillets/KNOWN_FAILING @@ -20,7 +20,6 @@ cov-fillet-g2-oblique-three-edge-corner the G2 corner patch meets the new order- cov-fillet-g2-pocket-corner the G2 corner patch meets the new order-2 section's rounds only G1 at one face seam (its volume holds); the corner step rebuilds the patch cov-fillet-turn-swept-boss-base-r1 not supported yet: solid.fillet has no `turn`; the corners are mitred (12508.9676, the Mitre case's volume) cov-fillet-turn-swept-pocket-sharp-corner-refused-r1 not supported yet: solid.fillet has no `turn`, so the sharp concave corners are mitred, not refused -cov-fillet-variable-box-edge-1-to-5-on-its-cone the variable round's sections are the balls' great circles, not the circles their envelope touches them along: volume 11955.6466 against 11956.2224 (rel 4.8e-5) cov-junction-boss-tilt-20-root-round SMLib fillet status 1001 on a cylinder tilted 20 degrees into the plate (also before the blend rework) cov-junction-boss-tilt-40-root-round SMLib fillet status 1001 on a cylinder tilted 40 degrees into the plate (also before the blend rework) cov-junction-tee-equal-round equal pipes' intersection is two plane ellipses crossing: their exact conic-pair rounds meet at the crossings in a corner the old corner code cannot join (built by the traced rounds before smlib#77); the corner step diff --git a/tests/kernel-cases/ladder/07-fillets/005-variable-r5-to-r1/expected.json b/tests/kernel-cases/ladder/07-fillets/005-variable-r5-to-r1/expected.json index 427fc65d5..d7bfe8ab5 100644 --- a/tests/kernel-cases/ladder/07-fillets/005-variable-r5-to-r1/expected.json +++ b/tests/kernel-cases/ladder/07-fillets/005-variable-r5-to-r1/expected.json @@ -2,8 +2,8 @@ "sources": [], "what": "a variable round on the top front edge, r5 at x=0 to r1 at x=60", "source": "analytic", - "method": "linear radius, quarter-round sections (tests/oracle/77): V = abc - (1-pi/4) L (a^2 + ab + b^2)/3", + "method": "linear radius: the balls' envelope, a cone (union of the balls: in each plane x = const the corner cut off by rays from it, each meeting the union first at the least entry over the balls, integrated over x): 132.858501 removed (the balls' great circles, (1-pi/4) L (a^2 + ab + b^2)/3 (tests/oracle/77), would take 133.053)", "body_count": 1, - "volume_mm3": 47866.946861306, + "volume_mm3": 47867.141499, "faces": 7 } diff --git a/tests/kernel-cases/ladder/07-fillets/006-variable-r5-to-zero/expected.json b/tests/kernel-cases/ladder/07-fillets/006-variable-r5-to-zero/expected.json index d240ef49b..e7600577b 100644 --- a/tests/kernel-cases/ladder/07-fillets/006-variable-r5-to-zero/expected.json +++ b/tests/kernel-cases/ladder/07-fillets/006-variable-r5-to-zero/expected.json @@ -2,8 +2,8 @@ "sources": [], "what": "a variable round on the top front edge, r5 at x=0 down to 0 at the x=60 vertex", "source": "analytic", - "method": "as 005 with b=0 (tests/oracle/78): the round closes to the corner, which stays", + "method": "as 005 with b=0 (tests/oracle/78): the cone's apex at the x=60 vertex, which stays; 107.055974 removed (great circles: 107.301)", "body_count": 1, - "volume_mm3": 47892.699081699, + "volume_mm3": 47892.944026, "faces": 7 } diff --git a/tests/kernel-cases/ladder/07-fillets/007-variable-r5-to-1e-3/expected.json b/tests/kernel-cases/ladder/07-fillets/007-variable-r5-to-1e-3/expected.json index 86e1a2278..6acfc42e0 100644 --- a/tests/kernel-cases/ladder/07-fillets/007-variable-r5-to-1e-3/expected.json +++ b/tests/kernel-cases/ladder/07-fillets/007-variable-r5-to-1e-3/expected.json @@ -2,8 +2,8 @@ "sources": [], "what": "a variable round on the top front edge, r5 down to 1e-3 mm", "source": "analytic", - "method": "as 005 with b = 1e-3: the round's end is a 1e-3 mm quarter circle on the end face", + "method": "as 005 with b = 1e-3: the round's end a 1e-3 mm circle on the end face; 107.077487 removed (great circles: 107.322)", "body_count": 1, - "volume_mm3": 47892.677617223, + "volume_mm3": 47892.922513, "faces": 7 } diff --git a/tests/kernel-cases/ladder/07-fillets/012-variable-into-rounded-corner/expected.json b/tests/kernel-cases/ladder/07-fillets/012-variable-into-rounded-corner/expected.json index ef89613a3..9cb3e8102 100644 --- a/tests/kernel-cases/ladder/07-fillets/012-variable-into-rounded-corner/expected.json +++ b/tests/kernel-cases/ladder/07-fillets/012-variable-into-rounded-corner/expected.json @@ -2,9 +2,9 @@ "sources": [], "what": "a vertical r5 round, then a variable round r1 -> r5 along the top back edge into it", "source": "analytic", - "method": "a variable round takes only its picked edge (no tangent chain: crates/doc/src/eval.rs), y = 40 from x = 0 (r1) to x = 55 (r5), where it meets the vertical r5 round's tangent line: removed (1-pi/4) 55 (1 + 5 + 25)/3 (005) and (1-pi/4) 5^2 20. Past x = 55 the round's end runs on into the vertical round's quarter column, trimmed by its cylinder: as a constant r5 tube that takes int_0^5 sqrt(25 - v^2)(5 - sqrt(25 - v^2)) dv = 125 pi/4 - 250/3 = 14.841437; with its radius still growing at 4/55 per mm, 15.854054 (numerical, the round's section against the cylinder). V lies between: graded as the interval's middle with its half width as the tolerance. Faces 6 + 2; edges 18, vertices 12 (5 round the bottom, 5 vertical, 5 round the top face, the round's line on the back wall, its end arc on x = 0, its trim on the cylinder)", + "method": "a variable round takes only its picked edge (no tangent chain: crates/doc/src/eval.rs), y = 40 from x = 0 (r1) to x = 55 (r5), where it meets the vertical r5 round's tangent line. The linear law's balls envelop a cone (union of the balls: in each plane x = const the corner cut off by rays from it, each meeting the union first at the least entry over the balls, integrated over x): 121.753137 removed along 55 (the great circles' (1-pi/4) 55 (1 + 5 + 25)/3 would take 121.965377), and (1-pi/4) 5^2 20 by the vertical round. Past x = 55 the round's end runs on into the vertical round's quarter column, trimmed by its cylinder: as a constant r5 tube that takes int_0^5 sqrt(25 - v^2)(5 - sqrt(25 - v^2)) dv = 125 pi/4 - 250/3 = 14.841437; with its radius still growing at 4/55 per mm (the cone going on), 15.820019 (the union of the balls, cut by the cylinder). V lies between: graded as the interval's middle with its half width as the tolerance. Faces 6 + 2; edges 18, vertices 12 (5 round the bottom, 5 vertical, 5 round the top face, the round's line on the back wall, its end arc on x = 0, its trim on the cylinder)", "body_count": 1, - "volume_mm3": 47755.385959062, + "volume_mm3": 47755.615217, "faces": 8, "edges": 18, "vertices": 12, @@ -21,6 +21,6 @@ ] }, "tolerance": { - "rel": 1.1602121611875055e-05 + "rel": 1.024573e-05 } }