1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Copy, Clone, Debug)]
pub struct Degrees(pub f32);
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Copy, Clone, Debug)]
pub struct Radians(pub f32);
impl Degrees {
pub fn new(angle: f32) -> Self {
Self(angle)
}
}
impl Radians {
pub fn new(angle: f32) -> Self {
Self(angle)
}
}
impl From<Radians> for Degrees {
fn from(item : Radians) -> Self {
Self(item.0 * 57.2958)
}
}
impl From<Degrees> for Radians {
fn from(item : Degrees) -> Self {
Self(item.0 * 0.017_453_3)
}
}