Use Radians in arc and ellipse types
This commit is contained in:
parent
8ed3490280
commit
c077e107f2
5 changed files with 74 additions and 26 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{Point, Rectangle, Vector};
|
||||
|
||||
use std::f32::consts::{FRAC_PI_2, PI};
|
||||
use std::ops::RangeInclusive;
|
||||
use std::ops::{Add, AddAssign, Div, Mul, RangeInclusive, Sub, SubAssign};
|
||||
|
||||
/// Degrees
|
||||
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
|
||||
|
|
@ -71,3 +71,47 @@ impl Radians {
|
|||
(start, end)
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<Radians> for Radians {
|
||||
fn sub_assign(&mut self, rhs: Radians) {
|
||||
self.0 = self.0 - rhs.0;
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Radians> for Radians {
|
||||
fn add_assign(&mut self, rhs: Radians) {
|
||||
self.0 = self.0 + rhs.0;
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Radians> for Radians {
|
||||
type Output = Radians;
|
||||
|
||||
fn add(self, rhs: Radians) -> Self::Output {
|
||||
Radians(self.0 + rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<Radians> for Radians {
|
||||
type Output = Radians;
|
||||
|
||||
fn sub(self, rhs: Radians) -> Self::Output {
|
||||
Radians(self.0 - rhs.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<f32> for Radians {
|
||||
type Output = Radians;
|
||||
|
||||
fn mul(self, rhs: f32) -> Self::Output {
|
||||
Radians(self.0 * rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<f32> for Radians {
|
||||
type Output = Radians;
|
||||
|
||||
fn div(self, rhs: f32) -> Self::Output {
|
||||
Radians(self.0 / rhs)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue