Rev 190 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 190 | Rev 194 | ||
---|---|---|---|
Line 12... | Line 12... | ||
12 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
13 | Peter Muehlenbrock |
13 | Peter Muehlenbrock |
14 | Winkelfunktionen sin, cos und arctan in |
14 | Winkelfunktionen sin, cos und arctan in |
15 | brute-force Art: Sehr Schnell, nicht sonderlich genau, aber ausreichend |
15 | brute-force Art: Sehr Schnell, nicht sonderlich genau, aber ausreichend |
16 | Sinus Funktion von Nick666 vereinfacht |
16 | Sinus Funktion von Nick666 vereinfacht |
17 | Stand 30.9.2007 |
17 | Stand 1.10.2007 |
18 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
18 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
19 | */ |
19 | */ |
20 | #include "main.h" |
20 | #include "main.h" |
Line 21... | Line 21... | ||
21 | 21 | ||
22 | 22 | ||
23 | // arctan Funktion: Eingabewert x,y Rueckgabe =arctan(x,y) in grad |
23 | // arctan Funktion: Eingabewert x,y Rueckgabe =arctan(x,y) in grad |
24 | int arctan_i(long signed int x, long signed int y) |
24 | int arctan_i( signed int x, signed int y) |
25 | { |
25 | { |
26 | short int change_xy = 0; |
26 | short int change_xy = 0; |
27 | long signed int i; |
27 | signed int i; |
Line 28... | Line 28... | ||
28 | long signed int wert; |
28 | long signed int wert; |
29 | int return_value; |
29 | int return_value; |
Line 42... | Line 42... | ||
42 | if ((y == 0) && (x == 0)) wert =1; // Division durch 0 nicht erlaubt |
42 | if ((y == 0) && (x == 0)) wert =1; // Division durch 0 nicht erlaubt |
43 | else wert= abs((x*1000)/y); |
43 | else wert= abs((x*1000)/y); |
Line 44... | Line 44... | ||
44 | 44 | ||
45 | if (wert <=268) //0...0.0,268 entsprechend 0..15 Grad |
45 | if (wert <=268) //0...0.0,268 entsprechend 0..15 Grad |
46 | { |
46 | { |
47 | return_value = (int)((wert*100)/(268-0)*(15-0)/100) +0; |
47 | return_value = (signed int)((wert*100)/(268-0)*(15-0)/100) +0; |
48 | } |
48 | } |
49 | else if (wert <=578) //0,268...0.0,568 entsprechend 15..30 Grad |
49 | else if (wert <=578) //0,268...0.0,568 entsprechend 15..30 Grad |
50 | { |
50 | { |
51 | return_value = (int)((((wert-268)*100)/(578-268)*(30-15))/100) +15; |
51 | return_value = (signed int)((((wert-268)*100)/(578-268)*(30-15))/100) +15; |
52 | } |
52 | } |
53 | else //0,568...1 entsprechend 30..45 Grad |
53 | else //0,568...1 entsprechend 30..45 Grad |
54 | { |
54 | { |
55 | return_value = (int)((((wert-578)*50)/(1000-578)*(45-30))/50) +30; |
55 | return_value = (signed int)((((wert-578)*50)/(1000-578)*(45-30))/50) +30; |
Line 56... | Line 56... | ||
56 | } |
56 | } |
57 | 57 | ||
58 | if (change_xy == 0) return_value = 90-return_value; //Quadrant 45..90 Grad |
58 | if (change_xy == 0) return_value = 90-return_value; //Quadrant 45..90 Grad |