+impl From<Degrees> for Point2D<f64> {
+ fn from(item: Degrees) -> Self {
+ Point2D {
+ x: (item.0 * std::f64::consts::PI / 180.0).cos(),
+ y: (item.0 * std::f64::consts::PI / 180.0).sin(),
+ }
+ }
+}
+
+impl From<Radians> for Point2D<f64> {
+ fn from(item: Radians) -> Self {
+ Point2D {
+ x: item.0.cos(),
+ y: item.0.sin(),
+ }
+ }
+}
+
+#[derive(Debug, PartialEq, Clone, Copy)]
+struct Degrees(f64);
+#[derive(Debug, PartialEq, Clone, Copy)]
+struct Radians(f64);
+
+impl Degrees {
+ fn to_radians(&self) -> Radians {
+ Radians(self.0 * std::f64::consts::PI / 180.0)
+ }
+}
+
+impl Radians {
+ fn to_degrees(&self) -> Degrees {
+ Degrees(self.0 * 180.0 * std::f64::consts::FRAC_1_PI)
+ }
+}
+