Merge pull request #1310 from gianlucafiore/fix-hatch-boundary-v2

Fix hatch arc direction for polyline boundaries
This commit is contained in:
gianlucafiore authored and GitHub committed 2026-09-16 09:18:10 -03:00
commit d894b8eb05
1 file changed
+27
+27
View File
@@ -203,9 +203,33 @@ pub(crate) fn ring_source_handles(
} }
fn curve_forward(curve: &Curve, start: [f64; 2], next: [f64; 2]) -> bool { fn curve_forward(curve: &Curve, start: [f64; 2], next: [f64; 2]) -> bool {
// For circular geometry, determine direction directly from the
// geometric traversal of the detected boundary. This avoids parameter
// wrap-around choosing the major arc instead of the minor arc.
match curve {
Curve::Circle(circle) => {
let ax = start[0] - circle.centre[0];
let ay = start[1] - circle.centre[1];
let bx = next[0] - circle.centre[0];
let by = next[1] - circle.centre[1];
ax * by - ay * bx >= 0.0
}
Curve::Arc(arc) => {
let ax = start[0] - arc.centre[0];
let ay = start[1] - arc.centre[1];
let bx = next[0] - arc.centre[0];
let by = next[1] - arc.centre[1];
ax * by - ay * bx >= 0.0
}
_ => {
let a = curve.parameter_at(start); let a = curve.parameter_at(start);
let b = curve.parameter_at(next); let b = curve.parameter_at(next);
let mut delta = b - a; let mut delta = b - a;
if curve.is_closed() { if curve.is_closed() {
if delta > 0.5 { if delta > 0.5 {
delta -= 1.0; delta -= 1.0;
@@ -213,7 +237,10 @@ fn curve_forward(curve: &Curve, start: [f64; 2], next: [f64; 2]) -> bool {
delta += 1.0; delta += 1.0;
} }
} }
delta >= 0.0 delta >= 0.0
}
}
} }
fn stored_arc_angles(start: f64, end: f64, counter_clockwise: bool, whole: bool) -> (f64, f64) { fn stored_arc_angles(start: f64, end: f64, counter_clockwise: bool, whole: bool) -> (f64, f64) {