#![doc = include_str!("../README.md")]
use std::f32::consts::{PI, TAU};
use umath::FF32;
const FRACT_PI_2: f32 = PI / 2.0;
#[inline]
pub fn cos(x: f32) -> f32 {
let x = unsafe { FF32::new(x) };
let mut y = x * unsafe { FF32::new(1.0 / TAU) };
y -= 0.25 + (y + 0.25).floor();
*(y * 16.0 * (y.abs() - 0.5))
}
#[inline]
pub fn sin(x: f32) -> f32 {
cos(x - FRACT_PI_2)
}
pub trait Sine {
fn cosf(self) -> Self;
fn sinf(self) -> Self;
}
impl Sine for f32 {
fn cosf(self) -> Self {
cos(self)
}
fn sinf(self) -> Self {
sin(self)
}
}