fix(dyn): an explicit minus keeps its sign in the angle field
The dynamic-input angle field stripped the typed sign and re-signed the value from the cursor's side of the X axis, so a negative angle could not be entered at all — 330 had to stand in for -30 (#417). An explicit -/+ prefix is now taken literally; unsigned entries keep the cursor-side behaviour. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
1c8d6e1978
commit
a7fd9ecb45
1 changed files with 11 additions and 5 deletions
|
|
@ -274,14 +274,20 @@ impl OpenCADStudio {
|
||||||
let live_a = dy.atan2(dx); // radians, in the UCS plane
|
let live_a = dy.atan2(dx); // radians, in the UCS plane
|
||||||
// A typed angle is shown unsigned (0..180); give it the sign of the
|
// A typed angle is shown unsigned (0..180); give it the sign of the
|
||||||
// cursor's current side so an entry made below the X axis sweeps
|
// cursor's current side so an entry made below the X axis sweeps
|
||||||
// downward to match the arc instead of mirroring up. Untyped → live.
|
// downward to match the arc instead of mirroring up. An EXPLICIT
|
||||||
|
// `-`/`+` prefix keeps its literal sign though — "-30" must mean
|
||||||
|
// −30° (= 330°) regardless of where the cursor sits (#417).
|
||||||
|
// Untyped → live.
|
||||||
let angle_rad = |idx: usize| -> f64 {
|
let angle_rad = |idx: usize| -> f64 {
|
||||||
match fields[idx]
|
let raw = fields[idx]
|
||||||
.buffer
|
.buffer
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.trim().replace(',', "."))
|
.map(|s| s.trim().replace(',', "."));
|
||||||
.and_then(|s| crate::app::expr_eval::eval_number(&s))
|
let explicit_sign = raw
|
||||||
{
|
.as_deref()
|
||||||
|
.is_some_and(|s| s.starts_with('-') || s.starts_with('+'));
|
||||||
|
match raw.and_then(|s| crate::app::expr_eval::eval_number(&s)) {
|
||||||
|
Some(v) if explicit_sign => v.to_radians(),
|
||||||
Some(mag) => mag.abs().to_radians().copysign(dy),
|
Some(mag) => mag.abs().to_radians().copysign(dy),
|
||||||
None => live_a,
|
None => live_a,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue