////////// ANGLE ///////////////////////////////////////////////////////////////
-#[derive(Debug, Default, PartialEq, Clone, Copy)]
+#[derive(Debug, Default, Clone, Copy)]
pub struct Angle(pub f64);
pub trait ToAngle {
}
}
-// TODO override eq, 0==360 osv
+impl PartialEq for Angle {
+ fn eq(&self, rhs: &Angle) -> bool {
+ self.0 % std::f64::consts::TAU == rhs.0 % std::f64::consts::TAU
+ }
+}
// addition and subtraction of angles
#[test]
fn angles() {
assert_eq!(0.radians(), 0.degrees());
+ assert_eq!(0.degrees(), 360.degrees());
assert_eq!(180.degrees(), std::f64::consts::PI.radians());
assert_eq!(std::f64::consts::PI.radians().to_degrees(), 180.0);
assert!((Point::from(90.degrees()) - point!(0.0, 1.0)).length() < 0.001);