diff --git a/src/modules/home/inquiry/area.rs b/src/modules/home/inquiry/area.rs index fbeb227fc..060a10579 100644 --- a/src/modules/home/inquiry/area.rs +++ b/src/modules/home/inquiry/area.rs @@ -41,14 +41,14 @@ impl CadCommand for AreaCommand { if self.points.len() < 3 { return CmdResult::Cancel; } - // Shoelace formula in the XZ plane (Y-up world) + // Shoelace formula in the world XY plane. let n = self.points.len(); let mut area_sum = 0.0f32; let mut perimeter = 0.0f32; for idx in 0..n { let a = self.points[idx]; let b = self.points[(idx + 1) % n]; - area_sum += a.x * b.z - b.x * a.z; + area_sum += a.x * b.y - b.x * a.y; perimeter += (b - a).length(); } let area = (area_sum * 0.5).abs(); diff --git a/src/modules/home/inquiry/dist.rs b/src/modules/home/inquiry/dist.rs index 4c179f2ad..7290c5917 100644 --- a/src/modules/home/inquiry/dist.rs +++ b/src/modules/home/inquiry/dist.rs @@ -33,10 +33,10 @@ impl CadCommand for DistCommand { let delta = pt - p1; let dist = delta.length(); let dx = delta.x; - let dy = delta.z; // Y-up world: Z is the "drawing Y" - let dz = delta.y; // Y-up world: Y is elevation + let dy = delta.y; // drawing plane is world XY + let dz = delta.z; // elevation - // Angle in XY plane (XZ in world coords) — degrees from +X + // Angle in XY plane — degrees from +X let angle_xy = dy.atan2(dx).to_degrees(); // Angle from XY plane toward Z (elevation angle) let dist_xy = dx.hypot(dy); diff --git a/src/modules/home/inquiry/id.rs b/src/modules/home/inquiry/id.rs index e8e8540d5..ac4aa2ed1 100644 --- a/src/modules/home/inquiry/id.rs +++ b/src/modules/home/inquiry/id.rs @@ -22,10 +22,10 @@ impl CadCommand for IdCommand { } fn on_point(&mut self, pt: Vec3) -> CmdResult { - // Y-up world: X stays X, Z→drawing Y, Y→elevation Z + // Drawing plane is world XY (z = elevation). let x = pt.x; - let y = pt.z; - let z = pt.y; + let y = pt.y; + let z = pt.z; let msg = format!("X = {x:.4}, Y = {y:.4}, Z = {z:.4}"); CmdResult::Measurement(msg) } diff --git a/src/modules/home/modify/align.rs b/src/modules/home/modify/align.rs index 0947a7460..5b76bb756 100644 --- a/src/modules/home/modify/align.rs +++ b/src/modules/home/modify/align.rs @@ -167,9 +167,9 @@ impl AlignCommand { ); } - // Angle from src_vec to dst_vec in XZ plane - let src_angle = src_vec.z.atan2(src_vec.x); - let dst_angle = dst_vec.z.atan2(dst_vec.x); + // Angle from src_vec to dst_vec in the world XY plane + let src_angle = src_vec.y.atan2(src_vec.x); + let dst_angle = dst_vec.y.atan2(dst_vec.x); let angle = dst_angle - src_angle; let scale_factor = if with_scale { dst_len / src_len } else { 1.0 }; diff --git a/src/modules/home/modify/fillet.rs b/src/modules/home/modify/fillet.rs index 729899f07..d81b873b7 100644 --- a/src/modules/home/modify/fillet.rs +++ b/src/modules/home/modify/fillet.rs @@ -1246,7 +1246,7 @@ impl CadCommand for FilletCommand { if handle.is_null() { return CmdResult::NeedPoint; } - let click = [pt.x as f64, pt.z as f64]; // Y-up: world Z = DXF Y + let click = [pt.x as f64, pt.y as f64]; // drawing plane is world XY match &self.step { FilletStep::WaitingForRadius => return CmdResult::NeedPoint, @@ -1324,7 +1324,7 @@ impl CadCommand for FilletCommand { if handle.is_null() { return vec![]; } - let click = [pt.x as f64, pt.z as f64]; + let click = [pt.x as f64, pt.y as f64]; match &self.step { FilletStep::WaitingForRadius => vec![], diff --git a/src/modules/home/modify/lengthen.rs b/src/modules/home/modify/lengthen.rs index e530e5878..5823b6a15 100644 --- a/src/modules/home/modify/lengthen.rs +++ b/src/modules/home/modify/lengthen.rs @@ -150,9 +150,9 @@ pub fn lengthen_entity(entity: &EntityType, pick_pt: Vec3, mode: &LenMode) -> Op } fn lengthen_line(line: &LineEnt, pick_pt: Vec3, mode: &LenMode) -> Option { - let s = Vec3::new(line.start.x as f32, line.start.z as f32, 0.0); - let e = Vec3::new(line.end.x as f32, line.end.z as f32, 0.0); - let p = Vec3::new(pick_pt.x, pick_pt.z, 0.0); + let s = Vec3::new(line.start.x as f32, line.start.y as f32, 0.0); + let e = Vec3::new(line.end.x as f32, line.end.y as f32, 0.0); + let p = Vec3::new(pick_pt.x, pick_pt.y, 0.0); let current_len = (e - s).length() as f64; if current_len < 1e-10 { @@ -187,7 +187,7 @@ fn lengthen_line(line: &LineEnt, pick_pt: Vec3, mode: &LenMode) -> Option Option { let cx = arc.center.x as f32; - let cy = arc.center.z as f32; // Y-up: DXF Y → world Z + let cy = arc.center.y as f32; // Current arc span let span = arc_span_rad(arc.start_angle, arc.end_angle); @@ -290,7 +290,7 @@ fn lengthen_ellipse(ell: &EllipseEnt, pick_pt: Vec3, mode: &LenMode) -> Option Option Option