Use circle planes in offset and break

This commit is contained in:
ramox81 committed 2026-08-21 16:49:56 +03:00
1 parent 390d42a63a
commit fc9110de21
2 files changed
+12 -4

No files matched your search

+10 -2
View File
@@ -126,8 +126,15 @@ fn break_circle(circle: &acadrust::entities::Circle, p1: DVec3, p2: DVec3) -> Ve
let cx = circle.center.x;
let cy = circle.center.y;
let a1 = angle_on_arc(cx, cy, p1);
let a2 = angle_on_arc(cx, cy, p2);
let plane = crate::entities::curve::circle_curve(circle).plane;
let Some(q1) = plane.project(p1.to_array()) else {
return vec![EntityType::Circle(circle.clone())];
};
let Some(q2) = plane.project(p2.to_array()) else {
return vec![EntityType::Circle(circle.clone())];
};
let a1 = angle_on_arc(cx, cy, DVec3::new(q1[0], q1[1], 0.0));
let a2 = angle_on_arc(cx, cy, DVec3::new(q2[0], q2[1], 0.0));
if (a1 - a2).abs() < 0.01 {
return vec![EntityType::Circle(circle.clone())];
@@ -139,6 +146,7 @@ fn break_circle(circle: &acadrust::entities::Circle, p1: DVec3, p2: DVec3) -> Ve
arc.common.handle = Handle::NULL;
arc.center = circle.center.clone();
arc.radius = circle.radius;
arc.thickness = circle.thickness;
arc.normal = circle.normal.clone();
arc.start_angle = a2;
arc.end_angle = a1;
+2 -2
View File
@@ -105,8 +105,8 @@ fn offset_xline(x: &XLineEnt, dist: f64, side_pt: Vec3) -> Option<EntityType> {
// ── Circle offset ──────────────────────────────────────────────────────────
fn offset_circle(c: &CircleEnt, dist: f64, side_pt: Vec3) -> Option<EntityType> {
let px = side_pt.x as f64;
let py = side_pt.y as f64;
let plane = crate::entities::curve::circle_curve(c).plane;
let [px, py] = plane.project(side_pt.as_dvec3().to_array())?;
let dc = ((px - c.center.x).powi(2) + (py - c.center.y).powi(2)).sqrt();
let new_r = if dc < c.radius {