mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-03 02:25:55 +00:00
Kernel loft test: the square-to-circle loft has the oracle's exact ruled volume, without printing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user