From 4c7d4f5c0305b99d6cb001c9ce4320ae4e19d064 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:54:27 -0400 Subject: [PATCH] Tessellation lens test: the lens's triangles fill exactly the rhombus through its arcs' midpoints Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tess/tests.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/kernel/src/tess/tests.rs b/crates/kernel/src/tess/tests.rs index 81730249d..befd7f9b3 100644 --- a/crates/kernel/src/tess/tests.rs +++ b/crates/kernel/src/tess/tests.rs @@ -862,7 +862,18 @@ fn a_face_bounded_by_two_short_arcs_keeps_an_area_to_mesh() { let made = ok(assemble(parts, false)); let (plan, _) = ok(plan(&made.brep, 0.5, None)); let lens = made.faces.first().and_then(|&f| plan.faces.get(f)).expect("the lens's plan"); - assert!(!lens.triangles.is_empty(), "the lens has triangles"); + // One round of halving puts a node at each arc's middle, (0, ±(r − c)) (the plane's (u, v) + // is its (x, y)): the triangles fill the rhombus with diagonals 2·half and 2(r − c). + let area: f64 = lens + .triangles + .iter() + .map(|t| { + let [a, b, c] = t.map(|i| lens.uv[i as usize]); + 0.5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])) + }) + .sum(); + let rhombus = 2.0 * half * (r - c); + assert!((area - rhombus).abs() < 1e-9 * rhombus, "{area} vs {rhombus}"); } /// Half of a square pyramid's sides as one spline face: degree 1, closed round the square