forked from microbuilder/LPC810_CodeBase
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsin_int16.h
More file actions
44 lines (40 loc) · 1.07 KB
/
sin_int16.h
File metadata and controls
44 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// from http://www.atwillys.de/content/cc/sine-lookup-for-embedded-in-c/
/**
* Example for a interpolated sine/cosine table lookup
*
* @file sin1.h
* @author stfwi
*
*/
#ifndef __SW__SIN1_H__
#define __SW__SIN1_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "stdint.h"
/**
* Sine calculation using interpolated table lookup.
* Instead of radiants or degrees we use "turns" here. Means this
* sine does NOT return one phase for 0 to 2*PI, but for 0 to 1.
* Input: -1 to 1 as int16 Q15 == -32768 to 32767.
* Output: -1 to 1 as int16 Q15 == -32768 to 32767.
*
* @param int16_t angle Q15
* @return int16_t Q15
*/
int16_t sin_int16(int16_t angle);
/**
* Cosine calculation using interpolated table lookup.
* Instead of radiants or degrees we use "turns" here. Means this
* cosine does NOT return one phase for 0 to 2*PI, but for 0 to 1.
* Input: -1 to 1 as int16 Q15 == -32768 to 32767.
* Output: -1 to 1 as int16 Q15 == -32768 to 32767.
*
* @param int16_t angle Q15
* @return int16_t Q15
*/
int16_t cos_int16(int16_t angle);
#ifdef __cplusplus
}
#endif
#endif