mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 02:25:55 +00:00
Tests: #1510's parts are weighed by their exact volumes, not 1e-3 mm meshes
a_split_in_the_plane_of_a_face_keeps_all_of_the_body held the two parts' volumes to the body's within a millionth, each read from a mesh at a 1e-3 mm chord. Nothing was lost: the parts came out at exactly the closed forms (780.3707 and 1035.2797 for the 5 mm groove, 1815.6504 together); the whole body's own mesh sagged 0.0034 mm³ short of that round the hole, twice the millionth. They are now SMLib's exact volumes (1e-8). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,11 +22,13 @@ fn plate(width: f64) -> Body {
|
||||
fn a_split_in_the_plane_of_a_face_keeps_all_of_the_body() {
|
||||
for width in [4.0, 5.0] {
|
||||
let b = plate(width);
|
||||
let v = b.volume_at(1e-3).unwrap();
|
||||
// Exact volumes (SMLib's, to 1e-8): a mesh's at a 1e-3 chord sags round the hole by more
|
||||
// than the millionth the parts are held to.
|
||||
let v = crate::measure(&b).unwrap().volume;
|
||||
let plane = Plane::from_normal(Vec3::new(0.0, 0.0, 1.5), Vec3::Z).unwrap();
|
||||
let parts = split_by_plane(&b, &plane).unwrap();
|
||||
assert_eq!(parts.len(), 2, "{width}");
|
||||
let vs: Vec<f64> = parts.iter().map(|p| p.volume_at(1e-3).unwrap()).collect();
|
||||
let vs: Vec<f64> = parts.iter().map(|p| crate::measure(p).unwrap().volume).collect();
|
||||
assert!((vs.iter().sum::<f64>() - v).abs() < 1e-6 * v, "{width}: {vs:?} against {v}");
|
||||
// Above: the plate from 1.5 to 2.5 less the hole; below: less the hole and the groove.
|
||||
let (r, h) = (2.5f64, width / 2.0);
|
||||
|
||||
Reference in New Issue
Block a user