Fast 8 and 16bit approximations of sin(x) and cos(x).
More...

LIB8STATIC int16_t  sin16_avr (uint16_t theta) 
 Fast 16bit approximation of sin(x). More...


LIB8STATIC int16_t  sin16_C (uint16_t theta) 
 Fast 16bit approximation of sin(x). More...


LIB8STATIC int16_t  cos16 (uint16_t theta) 
 Fast 16bit approximation of cos(x). More...


LIB8STATIC uint8_t  sin8_avr (uint8_t theta) 
 Fast 8bit approximation of sin(x). More...


LIB8STATIC uint8_t  sin8_C (uint8_t theta) 
 Fast 8bit approximation of sin(x). More...


LIB8STATIC uint8_t  cos8 (uint8_t theta) 
 Fast 8bit approximation of cos(x). More...



const uint8_t  b_m16_interleave [] = { 0, 49, 49, 41, 90, 27, 117, 10 } 

Fast 8 and 16bit approximations of sin(x) and cos(x).
Don't use these approximations for calculating the trajectory of a rocket to Mars, but they're great for art projects and LED displays.
On Arduino/AVR, the 16bit approximation is more than 10X faster than floating point sin(x) and cos(x), while the 8bit approximation is more than 20X faster.
LIB8STATIC int16_t cos16 
( 
uint16_t 
theta  ) 

Fast 16bit approximation of cos(x).
This approximation never varies more than 0.69% from the floating point value you'd get by doing
float s = cos(x) * 32767.0;
 Parameters

theta  input angle from 065535 
 Returns
 sin of theta, value between 32767 to 32767.
Definition at line 120 of file trig8.h.
LIB8STATIC uint8_t cos8 
( 
uint8_t 
theta  ) 

Fast 8bit approximation of cos(x).
This approximation never varies more than 2% from the floating point value you'd get by doing
float s = (cos(x) * 128.0) + 128;
 Parameters

theta  input angle from 0255 
 Returns
 sin of theta, value between 0 and 255
Definition at line 253 of file trig8.h.
LIB8STATIC int16_t sin16_avr 
( 
uint16_t 
theta  ) 

Fast 16bit approximation of sin(x).
This approximation never varies more than 0.69% from the floating point value you'd get by doing
float s = sin(x) * 32767.0;
 Parameters

theta  input angle from 065535 
 Returns
 sin of theta, value between 32767 to 32767.
Definition at line 30 of file trig8.h.
LIB8STATIC int16_t sin16_C 
( 
uint16_t 
theta  ) 

Fast 16bit approximation of sin(x).
This approximation never varies more than 0.69% from the floating point value you'd get by doing
float s = sin(x) * 32767.0;
 Parameters

theta  input angle from 065535 
 Returns
 sin of theta, value between 32767 to 32767.
Definition at line 88 of file trig8.h.
LIB8STATIC uint8_t sin8_avr 
( 
uint8_t 
theta  ) 

Fast 8bit approximation of sin(x).
This approximation never varies more than 2% from the floating point value you'd get by doing
float s = (sin(x) * 128.0) + 128;
 Parameters

theta  input angle from 0255 
 Returns
 sin of theta, value between 0 and 255
Definition at line 159 of file trig8.h.
LIB8STATIC uint8_t sin8_C 
( 
uint8_t 
theta  ) 

Fast 8bit approximation of sin(x).
This approximation never varies more than 2% from the floating point value you'd get by doing
float s = (sin(x) * 128.0) + 128;
 Parameters

theta  input angle from 0255 
 Returns
 sin of theta, value between 0 and 255
Definition at line 217 of file trig8.h.