From d100417433b12223fdb3ebe8d2700ca7173ef214 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 22 Oct 2026 13:13:40 -0400 Subject: [PATCH] kernel: emboss reads a wall's span from its arc's interval The angles a cylindrical wall spans came from its arc's two ends about its middle; a wall in one piece has a whole circle for an edge, whose ends are one point. The circle's parameter is its angle, so the span is the edge's interval about the angle of its middle: half the turn either side for a whole wall, as for any arc. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt --- crates/kernel/src/emboss.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/kernel/src/emboss.rs b/crates/kernel/src/emboss.rs index e4abdac27..11f65286a 100644 --- a/crates/kernel/src/emboss.rs +++ b/crates/kernel/src/emboss.rs @@ -20,15 +20,13 @@ fn angle(p: Vec3, o: Vec3, axis: Vec3, radial: Vec3, tangent: Vec3) -> f64 { let w = w - axis * w.dot(axis); w.dot(tangent).atan2(w.dot(radial)) } -fn unwrap(a: f64, around: f64) -> f64 { - around + (a - around + std::f64::consts::PI).rem_euclid(std::f64::consts::TAU) - std::f64::consts::PI -} fn arr(v: Vec3) -> [f64; 3] { [v.x, v.y, v.z] } /// The angles a wall face spans about the axis, seen from `radial`: from one of its arcs about -/// the axis (a face of one loop of four edges). +/// the axis (a face of one loop of four edge uses: two arcs and two lines, or a whole turn's two +/// circles and its seam used twice). fn wall_angles(b: &Brep, face: usize, o: Vec3, axis: Vec3, radial: Vec3, tangent: Vec3) -> Option<(f64, f64)> { let f = b.faces.get(face)?; let [Loop::Edges { edges }] = f.loops.as_slice() else { return None }; @@ -42,12 +40,13 @@ fn wall_angles(b: &Brep, face: usize, o: Vec3, axis: Vec3, radial: Vec3, tangent if z.dot(axis).abs() < 1.0 - 1e-9 { continue; } + // The circle's parameter is its angle: the wall spans the edge's interval about the + // angle of its middle (a whole turn, from the seam, for a wall in one piece). let c = CurveEval::new(&e.curve).ok()?; let [t0, t1] = e.interval; let am = angle(c.point(0.5 * (t0 + t1))?, o, axis, radial, tangent); - let aa = unwrap(angle(c.point(t0)?, o, axis, radial, tangent), am); - let ab = unwrap(angle(c.point(t1)?, o, axis, radial, tangent), am); - return Some((aa.min(ab), aa.max(ab))); + let half = 0.5 * (t1 - t0); + return Some((am - half, am + half)); } None }