mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-27 04:16:48 -06:00
Polar points and angle prompts read bare numbers in AUNITS (explicit d/r/g, deg-min-sec and bearings still work) and measure directions from ANGBASE in the ANGDIR sense; `d<<a` (degrees) and `d<<<a` (AUNITS) measure from +X counterclockwise. XLINE Reference turns per ANGDIR; included angles and sweeps take the units only. ANGBASE is held in radians like $ANGBASE in DXF; SETVAR reads and reports it in degrees. JSON params keep their meaning. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
771 B
Rust
19 lines
771 B
Rust
//! The angle settings round-trip through DXF: `$ANGBASE` (group 50) in radians, `$ANGDIR` and
|
|
//! `$AUNITS` (group 70) as integers.
|
|
|
|
use cadcraft_doc::{Drawing, HVal};
|
|
|
|
#[test]
|
|
fn angbase_angdir_aunits_round_trip_through_dxf() {
|
|
let mut d = Drawing::new_metric();
|
|
d.header.set_f64("ANGBASE", std::f64::consts::FRAC_PI_2);
|
|
d.header.set_i64("ANGDIR", 1);
|
|
d.header.set_i64("AUNITS", 3);
|
|
let text = cadcraft_io::write_dxf(&d);
|
|
let r = cadcraft_io::read_dxf(text.as_bytes()).unwrap();
|
|
let base = r.header.f64("ANGBASE", 0.0);
|
|
assert!((base - std::f64::consts::FRAC_PI_2).abs() < 1e-12, "$ANGBASE read back as {base}");
|
|
assert_eq!(r.header.get("ANGDIR"), Some(&HVal::Int(1)));
|
|
assert_eq!(r.header.get("AUNITS"), Some(&HVal::Int(3)));
|
|
}
|