Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | ARCTAN_APPROX(y, x) (-y * (47 * y - 182 * x) / 3 / x / x) |
Functions | |
int16_t | getSin1024 (int16_t degree) |
int16_t | getCos1024 (int16_t degree) |
int32_t | getTan1024 (int16_t degree) |
int32_t | cordicAtan2 (int32_t x, int32_t y) |
CORDIC approximation of arctan. | |
int16_t | getAtan2 (int32_t y, int32_t x) |
Calculate the angle of the line from the origin to (x, y), in degrees. | |
Variables | |
const int16_t | sin1024 [91] |
const uint16_t | tan1024 [91] |
#define ARCTAN_APPROX | ( | y, | |
x ) (-y * (47 * y - 182 * x) / 3 / x / x) |
Approximates arctan(y / x) to within 1 degree, but only when 0 <= (y / x) <= 1 Modified from https://math.stackexchange.com/a/1098585 to fit the format of your numbers.
int16_t getSin1024 | ( | int16_t | degree | ) |
Integer sine function
degree | The degree, between 0 and 359 |
int16_t getCos1024 | ( | int16_t | degree | ) |
Integer cosine function
degree | The degree, between 0 and 359 |
int32_t getTan1024 | ( | int16_t | degree | ) |
Integer tangent function
degree | The degree, between 0 and 359 |
int32_t cordicAtan2 | ( | int32_t | x, |
int32_t | y ) |
CORDIC approximation of arctan.
x | The x component |
y | The y component |
int16_t getAtan2 | ( | int32_t | y, |
int32_t | x ) |
Calculate the angle of the line from the origin to (x, y), in degrees.
If both x and y are 0, atan2 is undefined and will return 0.
y | The Y coordinate of the point to calculate the angle to |
x | The X coordinate of the point to calculate the angle to |
const int16_t sin1024[91] |
A table of the first 91 values of (1024 * sin(x)). Only 91 values are necessary because getSin1024() and getCos1024() handle symmetry to calculate the full wave
const uint16_t tan1024[91] |
A table of the first 91 values of (1024 * tan(x)). Only 91 values are necessary because getTan1024() handles symmetry to calculate the full wave