Minor cleanup

master
Mark 2023-12-25 16:15:09 -08:00
parent a5b3932e9d
commit 17aa76ac61
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
1 changed files with 7 additions and 23 deletions

View File

@ -63,17 +63,6 @@ pub(in crate::content) mod toml {
}
}
impl CoordinatesTwo {
/// Transform a CoordinatesThree into a CoordinatesTwo by adding a NaN z component.
/// Labels are not changed.
pub fn to_three(&self) -> CoordinatesThree {
match self {
Self::Label(s) => CoordinatesThree::Label(s.clone()),
Self::Coords(v) => CoordinatesThree::Coords([v[0], v[1], f32::NAN]),
}
}
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum CoordinatesThree {
@ -89,17 +78,6 @@ pub(in crate::content) mod toml {
}
}
}
impl CoordinatesThree {
/// Transform a CoordinatesThree into a CoordinatesTwo by deleting z component.
/// Labels are not changed.
pub fn to_two(&self) -> CoordinatesTwo {
match self {
Self::Label(s) => CoordinatesTwo::Label(s.clone()),
Self::Coords(v) => CoordinatesTwo::Coords([v[0], v[1]]),
}
}
}
}
#[derive(Debug)]
@ -158,7 +136,13 @@ fn resolve_position(
match &obj.position {
toml::Position::Cartesian(c) => Ok(resolve_coordinates(objects, &c, cycle_detector)?),
toml::Position::Polar(p) => {
let r = resolve_coordinates(&objects, &p.center.to_three(), cycle_detector)?;
let three = match &p.center {
toml::CoordinatesTwo::Label(s) => toml::CoordinatesThree::Label(s.clone()),
toml::CoordinatesTwo::Coords(v) => {
toml::CoordinatesThree::Coords([v[0], v[1], f32::NAN])
}
};
let r = resolve_coordinates(&objects, &three, cycle_detector)?;
let plane = Polar {
center: (r.x, r.y).into(),
radius: p.radius,