Rev 386 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 386 | Rev 391 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | int i,angle; |
26 | int i,angle; |
27 | int8_t m; |
27 | int8_t m; |
Line 28... | Line 28... | ||
28 | 28 | ||
Line 29... | Line 29... | ||
29 | if (!x && !y) return 0; //atan2 = 0 für x und y = 0 |
29 | if (!x && !y) return 0; //atan2 = 0 für x und y = 0 |
30 | - | ||
31 | if (y < 0) |
- | |
32 | { |
- | |
33 | m=-1; |
30 | |
Line 34... | Line 31... | ||
34 | } |
31 | if (y < 0) m=-1; |
Line 35... | Line 32... | ||
35 | else m=1; |
32 | else m=1; |
Line 55... | Line 52... | ||
55 | else if ((x < 0) && (m > 0)) return (-angle + 180); // Quadrant II |
52 | else if ((x < 0) && (m > 0)) return (-angle + 180); // Quadrant II |
56 | else return (angle - 180); // x < 0 && y < 0 Quadrant III |
53 | else return (angle - 180); // x < 0 && y < 0 Quadrant III |
57 | } |
54 | } |
Line 58... | Line 55... | ||
58 | 55 | ||
Line 59... | Line 56... | ||
59 | 56 | ||
60 | const float pgm_sinus_f [91] PROGMEM = {0.0,0.01745241,0.03489950,0.05233595,0.06975647,0.08715574,0.10452846,0.12186934,0.13917310,0.15643446,0.17364817,0.19080899,0.20791168,0.22495105,0.24192189,0.25881904,0.27563735,0.29237170,0.30901699,0.32556815,0.34202013,0.35836794,0.37460658,0.39073112,0.40673663,0.42261825,0.43837113,0.45399049,0.46947155,0.48480961,0.49999999,0.51503806,0.52991925,0.54463902,0.55919289,0.57357642,0.58778524,0.60181501,0.61566146,0.62932038,0.64278759,0.65605901,0.66913059,0.68199834,0.69465835,0.70710676,0.71933978,0.73135368,0.74314481,0.75470956,0.76604443,0.77714594,0.78801074,0.79863549,0.80901698,0.81915203,0.82903756,0.83867055,0.84804808,0.85716728,0.86602539,0.87461969,0.88294758,0.89100651,0.89879403,0.90630777,0.91354544,0.92050484,0.92718384,0.93358041,0.93969261,0.94551856,0.95105650,0.95630474,0.96126169,0.96592582,0.97029572,0.97437006,0.97814759,0.98162718,0.98480775,0.98768833,0.99026806,0.99254615,0.99452189,0.99619469,0.99756405,0.99862953,0.99939083,0.99984769,1.0}; |
57 | const float pgm_sinus_f[91] PROGMEM = {0.0,0.01745241,0.03489950,0.05233595,0.06975647,0.08715574,0.10452846,0.12186934,0.13917310,0.15643446,0.17364817,0.19080899,0.20791168,0.22495105,0.24192189,0.25881904,0.27563735,0.29237170,0.30901699,0.32556815,0.34202013,0.35836794,0.37460658,0.39073112,0.40673663,0.42261825,0.43837113,0.45399049,0.46947155,0.48480961,0.49999999,0.51503806,0.52991925,0.54463902,0.55919289,0.57357642,0.58778524,0.60181501,0.61566146,0.62932038,0.64278759,0.65605901,0.66913059,0.68199834,0.69465835,0.70710676,0.71933978,0.73135368,0.74314481,0.75470956,0.76604443,0.77714594,0.78801074,0.79863549,0.80901698,0.81915203,0.82903756,0.83867055,0.84804808,0.85716728,0.86602539,0.87461969,0.88294758,0.89100651,0.89879403,0.90630777,0.91354544,0.92050484,0.92718384,0.93358041,0.93969261,0.94551856,0.95105650,0.95630474,0.96126169,0.96592582,0.97029572,0.97437006,0.97814759,0.98162718,0.98480775,0.98768833,0.99026806,0.99254615,0.99452189,0.99619469,0.99756405,0.99862953,0.99939083,0.99984769,1.0}; |
61 | 58 | ||
62 | inline float pgm_read_float(const float *addr) |
59 | inline float pgm_read_float(const float *addr) |
Line 97... | Line 94... | ||
97 | winkel = abs(winkel); |
94 | winkel = abs(winkel); |
98 | } |
95 | } |
99 | else m = +1; |
96 | else m = +1; |
Line 100... | Line 97... | ||
100 | 97 | ||
- | 98 | // Quadranten auswerten |
|
101 | // Quadranten auswerten |
99 | if (winkel <= 90) n=1; |
102 | if ((winkel > 90 ) && (winkel <= 180)) {winkel = 180 - winkel; n = 1;} |
100 | else if ((winkel > 90 ) && (winkel <= 180)) {winkel = 180 - winkel; n = 1;} |
103 | else if ((winkel > 180 ) && (winkel <= 270)) {winkel = winkel - 180; n = -1;} |
101 | else if ((winkel > 180 ) && (winkel <= 270)) {winkel = winkel - 180; n = -1;} |
104 | else if ((winkel > 270) && (winkel <= 360)) {winkel = 360 - winkel; n = -1;} |
- | |
Line 105... | Line 102... | ||
105 | else n = 1; //0 - 90 Grad |
102 | else {winkel = 360 - winkel; n = -1;} //if ((winkel > 270) && (winkel <= 360)) |
Line 106... | Line 103... | ||
106 | 103 | ||
107 | sinus = pgm_read_float(&pgm_sinus_f[winkel]); |
104 | sinus = pgm_read_float(&pgm_sinus_f[winkel]); |
Line 120... | Line 117... | ||
120 | signed char m; |
117 | signed char m; |
Line 121... | Line 118... | ||
121 | 118 | ||
122 | if (i < 0) {m=-1;i=abs(i);} |
119 | if (i < 0) {m=-1;i=abs(i);} |
Line 123... | Line 120... | ||
123 | else m=1; |
120 | else m=1; |
Line 124... | Line 121... | ||
124 | 121 | ||
125 | if (i > 200) i = 200; |
122 | i = i % 200; |