Files
cadcraft/crates/io/tests/angle_header.rs
T
Valentin KleinandClaude Opus 5.5 b1a78fbb8f Typed angles follow ANGBASE, ANGDIR and AUNITS (fixes #326) (#328)
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>
2026-10-10 16:55:07 -04:00

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)));
}