Align arc creation and editing behavior

This commit is contained in:
ramox81 committed 2026-08-21 14:03:58 +03:00
1 parent 573ed3245e
commit 5f9d8a9e0e
15 files changed
+537 -337

No files matched your search

+9 -3
View File
@@ -96,9 +96,15 @@ fn break_arc(arc: &ArcEnt, p1: DVec3, p2: DVec3) -> Vec<EntityType> {
let cy = arc.center.y;
let r = arc.radius;
// Project p1 and p2 onto the arc (world XY plane)
let a1 = angle_on_arc(cx, cy, p1);
let a2 = angle_on_arc(cx, cy, p2);
let plane = crate::entities::curve::arc_curve(arc).plane;
let Some(q1) = plane.project(p1.to_array()) else {
return vec![EntityType::Arc(arc.clone())];
};
let Some(q2) = plane.project(p2.to_array()) else {
return vec![EntityType::Arc(arc.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));
let start = arc.start_angle;
let end = arc.end_angle;
+4 -17
View File
@@ -213,33 +213,20 @@ fn lengthen_line(line: &LineEnt, pick_pt: Vec3, mode: &LenMode) -> Option<Entity
}
fn lengthen_arc(arc: &ArcEnt, pick_pt: Vec3, mode: &LenMode) -> Option<EntityType> {
let cx = arc.center.x as f32;
let cy = arc.center.y as f32;
// Current arc span
let span = arc_span_rad(arc.start_angle, arc.end_angle);
let current_arc_len = arc.radius * span;
let new_arc_len = apply_mode(current_arc_len, mode)?;
if new_arc_len < 1e-10 {
if new_arc_len < 1e-10 || new_arc_len >= std::f64::consts::TAU * arc.radius - 1.0e-9 {
return None;
}
let new_span = new_arc_len / arc.radius;
// Which end (start or end angle) is closer to pick?
let start_rad = arc.start_angle;
let end_rad = arc.end_angle;
let start_pt = Vec3::new(
cx + arc.radius as f32 * start_rad.cos() as f32,
pick_pt.y,
cy + arc.radius as f32 * start_rad.sin() as f32,
);
let end_pt = Vec3::new(
cx + arc.radius as f32 * end_rad.cos() as f32,
pick_pt.y,
cy + arc.radius as f32 * end_rad.sin() as f32,
);
let curve = crate::entities::curve::arc_curve(arc);
let start_pt = Vec3::from_array(curve.point_at(0.0).map(|value| value as f32));
let end_pt = Vec3::from_array(curve.point_at(1.0).map(|value| value as f32));
let dist_start = (pick_pt - start_pt).length();
let dist_end = (pick_pt - end_pt).length();
+2 -2
View File
@@ -127,8 +127,8 @@ fn offset_circle(c: &CircleEnt, dist: f64, side_pt: Vec3) -> Option<EntityType>
// ── Arc offset ─────────────────────────────────────────────────────────────
fn offset_arc(a: &ArcEnt, 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::arc_curve(a).plane;
let [px, py] = plane.project(side_pt.as_dvec3().to_array())?;
let dc = ((px - a.center.x).powi(2) + (py - a.center.y).powi(2)).sqrt();
let new_r = if dc < a.radius {