Minor cleanup
parent
a5b3932e9d
commit
17aa76ac61
|
@ -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)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum CoordinatesThree {
|
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)]
|
#[derive(Debug)]
|
||||||
|
@ -158,7 +136,13 @@ fn resolve_position(
|
||||||
match &obj.position {
|
match &obj.position {
|
||||||
toml::Position::Cartesian(c) => Ok(resolve_coordinates(objects, &c, cycle_detector)?),
|
toml::Position::Cartesian(c) => Ok(resolve_coordinates(objects, &c, cycle_detector)?),
|
||||||
toml::Position::Polar(p) => {
|
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 {
|
let plane = Polar {
|
||||||
center: (r.x, r.y).into(),
|
center: (r.x, r.y).into(),
|
||||||
radius: p.radius,
|
radius: p.radius,
|
||||||
|
|
Loading…
Reference in New Issue