mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-04 11:05:56 +00:00
Kernel pocket floor fillet test: the corner rounds and the floor loop round add their exact volumes, by Pappus at the corners
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1380,18 +1380,23 @@ fn pocket_floor_loop_fillet() {
|
||||
cur = fillet(&cur, &[Vec3::new(65.0, 15.0, 16.0), Vec3::new(15.0, 15.0, 16.0), Vec3::new(65.0, 45.0, 16.0), Vec3::new(15.0, 45.0, 16.0)], 5.0)
|
||||
.unwrap();
|
||||
let v1 = measure(&cur).unwrap().volume;
|
||||
// The 50 x 30 x 8 pocket, less the four concave R5 rounds of its corners filling r²(1 − π/4)
|
||||
// of section along their 8.
|
||||
let want1 = 80.0 * 60.0 * 20.0 - 50.0 * 30.0 * 8.0 + 4.0 * 25.0 * (1.0 - PI / 4.0) * 8.0;
|
||||
assert!(rel(v1, want1) < 1e-6, "{v1} vs {want1}");
|
||||
let floor: Vec<Vec3> = [(40.0, 15.0), (65.0, 30.0), (40.0, 45.0), (15.0, 30.0)].iter().map(|(x, y)| Vec3::new(*x, *y, 12.0)).collect();
|
||||
let mut pts = floor.clone();
|
||||
let d = 5.0 - 5.0 / 2f64.sqrt();
|
||||
pts.extend([(15.0 + d, 15.0 + d), (65.0 - d, 15.0 + d), (65.0 - d, 45.0 - d), (15.0 + d, 45.0 - d)].iter().map(|(x, y)| Vec3::new(*x, *y, 12.0)));
|
||||
let f = fillet(&cur, &pts, 2.0).unwrap();
|
||||
let m = measure(&f).unwrap();
|
||||
// Added: the fillet profile (r²(1 − π/4)) swept along the floor outline (Pappus for the
|
||||
// corners: the profile's centroid sits 2 − 4·2/(3(4 − π))·… inward; check loosely).
|
||||
let straight = 2.0 * (40.0 + 20.0);
|
||||
let added_lines = (4.0 - PI) * straight;
|
||||
assert!(m.volume > v1 + added_lines && m.volume < v1 + added_lines + 4.0 * 2.0 * PI * 5.0, "{} {}", m.volume, v1);
|
||||
println!("pocket: {:?} vol {}", m.merged, m.volume);
|
||||
// Added: the R2 round's section, a = r²(1 − π/4), along the floor outline's straight 2(40 + 20),
|
||||
// and round its four R5 corners by Pappus: a quarter turn each at the radius of the section's
|
||||
// centroid, which sits r(10 − 3π)/(3(4 − π)) in from the wall, at 5 from the corner's axis.
|
||||
let a = 4.0 * (1.0 - PI / 4.0);
|
||||
let centroid = 5.0 - 2.0 * (10.0 - 3.0 * PI) / (3.0 * (4.0 - PI));
|
||||
let want = v1 + a * 2.0 * (40.0 + 20.0) + 4.0 * a * (PI / 2.0) * centroid;
|
||||
assert!(rel(m.volume, want) < 1e-6, "{} vs {want}", m.volume);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user