[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
как синус реализовали в компиляторе HI-TECH :
float eval_poly(float x, const float * d, int n) {
int i ;
float res ;
res = d[i = n];
while(i) res = x * res + d[ --i] ;
return res ;
}
float my_sin(float f) {
const static float coeff_a[] = {
207823.68416961012,
-76586.415638846949,
7064.1360814006881,
-237.85932457812158,
2.8078274176220686
} ;
const static float coeff_b[] = {
132304.66650864931,
5651.6867953169177,
108.99981103712905,
1.0
} ;
float x2 ;
int sgn ;
sgn = 0 ;
if( f < 0.0) {
f = -f ;
sgn = 1 ;
}
f *= 1.0/TWO_PI ;
f = 4.0 * (f - floor(f)) ;
if( f > 2.0) {
f -= 2.0 ;
sgn = !sgn ;
}
if( f > 1.0) f = 2.0 - f ;
x2 = f * f ;
f *= eval_poly( x2, coeff_a, 4) / eval_poly( x2, coeff_b, 3) ;
if( sgn) return -f ;
return f ;
}
E-mail: info@telesys.ru