forked from 1b-agent/opencadstudio-upstream
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 <[email protected]>
This commit is contained in:
1 parent
f6503ad4d3
commit
fa00c27e31
1 file changed
+6
-2
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user