Add bisection method for angles
This commit is contained in:
parent
8df5b14477
commit
3449fe8a73
1 changed files with 8 additions and 0 deletions
|
@ -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() }
|
||||
|
|
Loading…
Reference in a new issue