root/applications/pmsm/simulator_zdenek/ekf_example/qmath.cpp @ 1464

Revision 1464, 0.6 kB (checked in by smidl, 12 years ago)

upravy choleskiho + nove qmath

Line 
1#include "math.h"
2#include "fixed.h"
3
4typedef short int int16 ;
5typedef int int32 ;
6
7/* sin (theta), theta=-32768..32768 -> -pi,pi*/
8int16 qsin(int16 theta){
9        int16 t_sin;
10        int32 tmp;
11        tmp = prevod(sin(3.141593*(theta)/32768.),15);
12        if (tmp>32767) t_sin =32767; else t_sin=tmp;
13        return t_sin;
14}
15int16 qcos(int16 theta){
16        int16 t_cos;
17        int32 tmp;
18        tmp = prevod(cos(3.141593*(theta)/32768.),15);
19        if (tmp>32767) t_cos =32767; else t_cos=tmp;
20        return t_cos;
21}
22int16 qsqrt(int16 x){
23        int16 tmp;
24        tmp = prevod(sqrt((double)x/32768.),15);
25}
26int16 qlog(int16 x){
27        if (x<=0) 
28                return -32768;
29        else
30                return prevod(log(x/32768.),15);
31}
Note: See TracBrowser for help on using the browser.