avr-fw-modules/core/src/fp4816_sincos_slow.c

45 lines
881 B
C
Executable File

#include <fixpoint/fp4816.h>
fp4816_t fp4816_sin090_slow(fp4816_t rad) {
return fp4816_taylor(rad,10);
};
fp4816_t fp4816_cos_slow(fp4816_t rad) {
return fp4816_sin_slow( rad + FP4816_05PI );
}
fp4816_t fp4816_sin_slow(fp4816_t rad) {
if (
(rad >= FP4816_2PI) ||
(rad < 0)
) {
rad %= FP4816_2PI;
if (rad < 0) {
rad += FP4816_2PI;
};
};
if (
(rad == (FP4816_PI)) ||
(rad == 0)
) {
return 0;
};
if (rad == (FP4816_05PI)) {
return 65536L;
} else if (rad == (FP4816_15PI)) {
return -65536L;
} else if (rad < FP4816_05PI){
return fp4816_sin090_slow( rad );
} else if (rad < FP4816_PI){
return fp4816_sin090_slow( FP4816_PI - rad );
} else if (rad < FP4816_15PI){
return -fp4816_sin090_slow( rad - FP4816_PI );
} else if (rad < FP4816_2PI){
return -fp4816_sin090_slow( FP4816_2PI - rad );
};
return fp4816_from_int32( 2 );
};