From fa00c27e31dc5f38ad76768189f63aa5d27b50f2 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 13 Oct 2026 11:22:53 +0300 Subject: [PATCH] fix(dist): count the XY angle from ANGBASE in ANGDIR's sense DIST printed the raw world angle (-180..180) while the Properties panel and typed directions follow the drawing's base angle and direction. Co-Authored-By: Claude Opus 5.5 --- src/modules/draw/inquiry/dist.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/draw/inquiry/dist.rs b/src/modules/draw/inquiry/dist.rs index baa38796f..dd8386cc3 100644 --- a/src/modules/draw/inquiry/dist.rs +++ b/src/modules/draw/inquiry/dist.rs @@ -49,8 +49,12 @@ impl CadCommand for DistCommand { let dy = delta.y; let dz = delta.z; - // Angle in XY plane — degrees from +X - let angle_xy = dy.atan2(dx).to_degrees(); + // Angle in XY plane — a direction, so counted from ANGBASE the + // way ANGDIR runs, like every other direction the drawing shows. + let ctx = unit_context(); + let sign = if ctx.angdir_cw { -1.0 } else { 1.0 }; + let turn = std::f64::consts::TAU; + let angle_xy = (sign * (dy.atan2(dx) - ctx.angbase)).rem_euclid(turn).to_degrees(); // Angle from XY plane toward Z (elevation angle) let dist_xy = dx.hypot(dy); let angle_z = dz.atan2(dist_xy).to_degrees();