#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct Degrees(pub f64);
impl Degrees {
pub const fn new_unchecked(value: f64) -> Self {
Degrees(value)
}
pub fn new(value: f64) -> Self {
Degrees(value)
}
pub const fn get(&self) -> f64 {
self.0
}
pub fn to_radians(self) -> Radians {
Radians::new_unchecked(self.0.to_radians())
}
}
impl From<f64> for Degrees {
fn from(value: f64) -> Self {
Self::new(value)
}
}
impl From<Degrees> for f64 {
fn from(degrees: Degrees) -> Self {
degrees.get()
}
}
#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct Radians(pub f64);
impl Radians {
pub const fn new_unchecked(value: f64) -> Self {
Radians(value)
}
pub fn new(value: f64) -> Self {
use std::f64::consts::TAU; let normalized = value % TAU;
Radians(if normalized < 0.0 {
normalized + TAU
} else {
normalized
})
}
pub const fn get(&self) -> f64 {
self.0
}
pub fn to_degrees(self) -> Degrees {
Degrees::new_unchecked(self.0.to_degrees())
}
}
impl From<f64> for Radians {
fn from(value: f64) -> Self {
Self::new(value)
}
}
impl From<Radians> for f64 {
fn from(radians: Radians) -> Self {
radians.get()
}
}