mirror of
https://github.com/buhman/nds.git
synced 2025-06-18 14:35:38 -04:00
24 lines
430 B
C
24 lines
430 B
C
#include <stdint.h>
|
|
|
|
#include "math.h"
|
|
|
|
extern const uint16_t cos_table_fp12[];
|
|
|
|
int cos_fp12(int theta)
|
|
{
|
|
theta = abs(theta);
|
|
while (theta > 360) {
|
|
theta -= 360;
|
|
}
|
|
|
|
if (theta <= 90) {
|
|
return cos_table_fp12[theta];
|
|
} else if (theta <= 180) {
|
|
return - cos_table_fp12[180 - theta];
|
|
} else if (theta <= 270) {
|
|
return - cos_table_fp12[theta - 180];
|
|
} else {
|
|
return cos_table_fp12[360 - theta];
|
|
}
|
|
}
|