- /******************************************************************
- *
- * File Name: pw_sin.h
- * Description: The sin() function map. Using it to calculate a
- * angle's sine value and cosine value.
- * e.g.
- * angle d=30 degrees,
- * sin(d) = (sin_map[30] >> SIN_MAP_SHIFT)
- * result: sin(30) = 0.5
- *
- * Author : Jiang Peifu
- */
- #ifndef PW_SIN_H
- #define PW_SIN_H
- /* -------------------------------------------------------------------------- */
- #define SIN_MAP_SHIFT 15
- #define DEGREE_MIN 0
- #define DEGREE_MAX 90
- #define SIN_MAP_SIZE (DEGREE_MAX - DEGREE_MIN + 1)
- #define rsin(_r_, _d_) ((_r_ * sin_map[_d_] + 0x4000) >> SIN_MAP_SHIFT)
- #define rcos(_r_, _d_) ((_r_ * sin_map[DEGREE_MAX-_d_] + 0x4000) >> SIN_MAP_SHIFT)
- int sin_map[SIN_MAP_SIZE] = {
- 0,
- 572,
- 1144,
- 1715,
- 2286,
- 2856,
- 3425,
- 3993,
- 4560,
- 5126,
- 5690,
- 6252,
- 6813,
- 7371,
- 7927,
- 8481,
- 9032,
- 9580,
- 10126,
- 10668,
- 11207,
- 11743,
- 12275,
- 12803,
- 13328,
- 13848,
- 14365,
- 14876,
- 15384,
- 15886,
- 16384,
- 16877,
- 17364,
- 17847,
- 18324,
- 18795,
- 19261,
- 19720,
- 20174,
- 20622,
- 21063,
- 21498,
- 21926,
- 22348,
- 22763,
- 23170,
- 23571,
- 23965,
- 24351,
- 24730,
- 25102,
- 25466,
- 25822,
- 26170,
- 26510,
- 26842,
- 27166,
- 27482,
- 27789,
- 28088,
- 28378,
- 28660,
- 28932,
- 29197,
- 29452,
- 29698,
- 29935,
- 30163,
- 30382,
- 30592,
- 30792,
- 30983,
- 31164,
- 31336,
- 31499,
- 31651,
- 31795,
- 31928,
- 32052,
- 32166,
- 32270,
- 32365,
- 32449,
- 32524,
- 32588,
- 32643,
- 32688,
- 32723,
- 32748,
- 32763,
- 32768,
- };
- #endif /* PW_SIN_H */
- //该片段来自于http://www.codesnippet.cn/detail/250220132220.html
来源: http://www.codesnippet.cn/detail/250220132220.html