Another project
1use bone_types::Length;
2use uom::si::length::millimeter;
3
4#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
5pub struct Curvature(f64);
6
7impl Curvature {
8 pub const ZERO: Self = Self(0.0);
9
10 #[must_use]
11 pub fn from_radius(radius: Length) -> Self {
12 Self(1.0 / radius.get::<millimeter>())
13 }
14
15 #[must_use]
16 pub const fn value_per_mm(self) -> f64 {
17 self.0
18 }
19
20 #[must_use]
21 pub fn with_sign(self, sign: f64) -> Self {
22 Self(self.0 * sign.signum())
23 }
24}
25
26impl core::fmt::Display for Curvature {
27 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
28 write!(f, "k={}/mm", self.0)
29 }
30}