forked from 1b-agent/opencadstudio-upstream
refactor(trim): find boundary crossings with cadkernel
`line_seg_ts`, `arc_seg_ts`, `ellipse_seg_ts` and `spline_seg_ts` each walked every boundary kind and solved that pair by hand — four nested matches over the same seven cases. They are now four descriptions of the target as a `Curve` handed to one `cut_params`, which asks the kernel. Their signatures are unchanged, so the twenty call sites are untouched. Three things follow from it. Boundary splines and target splines stop being sampled. A cut on a spline now lands where the boundary actually crosses rather than where a fixed sampling said it did, because the kernel subdivides and converges to a tolerance instead. Rays and infinite lines as boundaries are handled by the kernel's extent rather than by a case here — a ray rejecting what lies behind its origin is the kernel's job now. `extend_spline` shoots a real ray. It used to build a line a million units long and cut against that, which both invents a limit and, at survey coordinates, is comparable to the coordinates themselves. The ray's direction is a unit vector, so what comes back is the distance to the boundary. That also fixes the hit position, which multiplied by the million-unit extent a second time and landed the extended end far past where it was supposed to. `cut_params` clamps to 0..=1 only for a bounded target; a ray has to keep the parameter it comes back with, since the distance is the answer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5bd5c884e0
commit
dde5ac07cf
3 files changed
+171
-601
No files matched your search
@@ -51,11 +51,6 @@ pub fn line_circle(px: f64, py: f64, dx: f64, dy: f64, cx: f64, cy: f64, r: f64)
|
||||
geom2d::line_circle([px, py], [dx, dy], [cx, cy], r)
|
||||
}
|
||||
|
||||
/// Angles **on the first circle** where two circles meet.
|
||||
pub fn circle_circle_angles(cx1: f64, cy1: f64, r1: f64, cx2: f64, cy2: f64, r2: f64) -> Vec<f64> {
|
||||
geom2d::circle_circle_angles([cx1, cy1], r1, [cx2, cy2], r2)
|
||||
}
|
||||
|
||||
/// `(s_on_line, t_on_ellipse)` pairs where a line meets an ellipse.
|
||||
///
|
||||
/// `nx, ny` is the unit major axis.
|
||||
|
||||
Reference in new issue
Block a user