mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
fix cos function
This commit is contained in:
parent
539caf7ad9
commit
548dd9ff67
|
@ -533,17 +533,10 @@ impl<I: FixedWidthSignedInteger, const N: usize> Num<I, N> {
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn cos(self) -> Self {
|
pub fn cos(self) -> Self {
|
||||||
let one: Self = I::one().into();
|
|
||||||
let mut x = self;
|
let mut x = self;
|
||||||
let four: I = 4.into();
|
x -= num!(0.25) + (x + num!(0.25)).floor();
|
||||||
let two: I = 2.into();
|
x *= (x.abs() - num!(0.5)) * num!(16.);
|
||||||
let sixteen: I = 16.into();
|
x += x * (x.abs() - num!(1.)) * num!(0.225);
|
||||||
let nine: I = 9.into();
|
|
||||||
let forty: I = 40.into();
|
|
||||||
|
|
||||||
x -= one / four + (x + one / four).floor();
|
|
||||||
x *= (x.abs() - one / two) * sixteen;
|
|
||||||
x += x * (x.abs() - one) * (nine / forty);
|
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue