Rev 242 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 242 | Rev 258 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; |
3 | it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; |
4 | either version 3 of the License, or (at your option) any later version. |
4 | either version 3 of the License, or (at your option) any later version. |
5 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
5 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
6 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7 | GNU General Public License and GNU Lesser General Public License for more details. |
7 | GNU General Public License and GNU Lesser General Public License for more details. |
8 | You should have received a copy of GNU General Public License ((License_GPL.txt) and |
8 | You should have received a copy of GNU General Public License (License_GPL.txt) and |
9 | GNU Lesser General Public License (License_LGPL.txt) along with this program. |
9 | GNU Lesser General Public License (License_LGPL.txt) along with this program. |
10 | If not, see <http://www.gnu.org/licenses/>. |
10 | If not, see <http://www.gnu.org/licenses/>. |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | Please note: All the other files for the project "Mikrokopter" by H.Buss are under the license (license_buss.txt) published by www.mikrokopter.de |
12 | Please note: All the other files for the project "Mikrokopter" by H.Buss are under the license (license_buss.txt) published by www.mikrokopter.de |
13 | */ |
13 | */ |
14 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
15 | Peter Muehlenbrock |
15 | Peter Muehlenbrock |
16 | Winkelfunktionen sin, cos und arctan in |
16 | Winkelfunktionen sin, cos und arctan in |
17 | brute-force Art: Sehr Schnell, nicht sonderlich genau, aber ausreichend |
17 | brute-force Art: Sehr Schnell, nicht sonderlich genau, aber ausreichend |
18 | Sinus Funktion von Nick666 vereinfacht |
18 | get_dist Funktion fuer Entfernungsermittlung |
19 | Stand 1.10.2007 |
19 | Stand 1.10.2007 |
20 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
20 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
21 | */ |
21 | */ |
Line 40... | Line 40... | ||
40 | 40 | ||
Line 41... | Line 41... | ||
41 | // Quadranten ermitteln |
41 | // Quadranten ermitteln |
42 | 42 | ||
43 | // Wert durch lineare Interpolation ermitteln |
43 | // Wert durch lineare Interpolation ermitteln |
Line 44... | Line 44... | ||
44 | if ((y == 0) && (x == 0)) wert =1; // Division durch 0 nicht erlaubt |
44 | if ((y == 0) && (x == 0)) wert =1; // Division durch 0 nicht erlaubt |
45 | else wert= abs((x*1000)/y); |
45 | else wert= abs(((long) x*1000)/((long)y)); |
46 | 46 | ||
47 | if (wert <=268) //0...0.0,268 entsprechend 0..15 Grad |
47 | if (wert <=268) //0...0.0,268 entsprechend 0..15 Grad |
Line 106... | Line 106... | ||
106 | winkel = pgm_read_word(&pgm_sinus[winkel]); |
106 | winkel = pgm_read_word(&pgm_sinus[winkel]); |
107 | return (winkel*m*n); |
107 | return (winkel*m*n); |
108 | } |
108 | } |
Line 109... | Line 109... | ||
109 | 109 | ||
110 | // Aus x,y und Winkel Distanz ermitteln |
110 | // Aus x,y und Winkel Distanz ermitteln |
111 | long get_dist(signed int x, signed int y, signed int phi) |
111 | int get_dist(signed int x, signed int y, signed int phi) |
112 | { |
112 | { |
113 | long dist; |
113 | long dist; |
114 | if (abs(x) > abs(y) ) |
114 | if (abs(x) > abs(y) ) |
115 | { |
115 | { |
Line 119... | Line 119... | ||
119 | else |
119 | else |
120 | { |
120 | { |
121 | dist = (long) y; |
121 | dist = (long) y; |
122 | dist = abs((dist *1000) / (long) cos_i(phi)); |
122 | dist = abs((dist *1000) / (long) cos_i(phi)); |
123 | } |
123 | } |
124 | return dist; |
124 | return (int)dist; |
125 | } |
125 | } |