esp32-sk6812/include/fasttrigon.h

35 lines
779 B
C++

/*!
* \file
*
* This file contains function prototypes for very fast lookup-table based
* trigonometric functions.
*
* The functions take an argument that is dependent on the lookup-table size
* (LUT_SIZE). LUT_SIZE corresponds to 2π. Values outside the range
* [0..LUT_SIZE] are supported and interpreted normally, so just replace 2π
* with LUT_SIZE and you're done.
*/
#pragma once
#include <cstdint>
namespace fasttrigon {
static const uint32_t LUT_SIZE = 1024;
/*!
* \returns 127 * sin(2π * arg / LUT_SIZE)
*/
int32_t fastsin(int32_t arg);
/*!
* \returns 127 * cos(2π * arg / LUT_SIZE)
*/
int32_t fastcos(int32_t arg);
/*!
* \returns 127 * tan(2π * arg / LUT_SIZE)
*/
int32_t fasttan(int32_t arg);
}