Add bisection method for angles

This commit is contained in:
Brendan Zabarauskas 2013-09-17 16:40:29 +10:00
parent 8df5b14477
commit 3449fe8a73

View file

@ -110,6 +110,12 @@ pub trait Angle
self.add_a(Angle::turn_div_2()).normalize()
}
/// Returns the interior bisector of the two angles
#[inline]
fn bisect(&self, other: Self) -> Self {
self.add_a(self.sub_a(other).mul_s(cast(0.5))).normalize()
}
fn full_turn() -> Self;
#[inline] fn turn_div_2() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(2)) }
@ -118,6 +124,8 @@ pub trait Angle
#[inline] fn turn_div_6() -> Self { let full_turn: Self = Angle::full_turn(); full_turn.div_s(cast(6)) }
}
#[inline] pub fn bisect<S: Float, A: Angle<S>>(a: A, b: A) -> A { a.bisect(b) }
impl<S: Float> Rad<S> {
#[inline] pub fn zero() -> Rad<S> { zero() }
#[inline] pub fn full_turn() -> Rad<S> { Angle::full_turn() }