Trait float_approx_math::ApproxSin
source · pub trait ApproxSin {
// Required method
fn approx_sin(self) -> Self;
}
Required Methods§
sourcefn approx_sin(self) -> Self
fn approx_sin(self) -> Self
Calculates an approximation of a sine, using the Z80 / ZX Spectrum algorithm.
https://namoseley.wordpress.com/2012/09/26/arduinoavr-and-zx-spectrum-sin-routines/
This approximation is significantly slower than the built-in sin method in the standard library, however this method can be run at compile-time.
Example
#![feature(const_trait_impl)]
use float_approx_math::ApproxSin;
const X: f32 = 2.0;
let y: f32 = X.approx_sin();
assert!((y - X.sin()).abs() < 0.0000005); // Less than 0.0000005 abs error
Object Safety§
This trait is not object safe.