diff --git a/src/cgmath/angle.rs b/src/cgmath/angle.rs index 83a479d..c7a64d2 100644 --- a/src/cgmath/angle.rs +++ b/src/cgmath/angle.rs @@ -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>(a: A, b: A) -> A { a.bisect(b) } + impl Rad { #[inline] pub fn zero() -> Rad { zero() } #[inline] pub fn full_turn() -> Rad { Angle::full_turn() }