14,7 → 14,7 |
Winkelfunktionen sin, cos und arctan in |
brute-force Art: Sehr Schnell, nicht sonderlich genau, aber ausreichend |
Sinus Funktion von Nick666 vereinfacht |
Stand 28.9.2007 |
Stand 30.9.2007 |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
*/ |
#include "main.h" |
24,7 → 24,7 |
int arctan_i(long signed int x, long signed int y) |
{ |
short int change_xy = 0; |
signed int i; |
long signed int i; |
long signed int wert; |
int return_value; |
|
39,7 → 39,8 |
// Quadranten ermitteln |
|
// Wert durch lineare Interpolation ermitteln |
wert= abs((x*1000)/y); |
if ((y == 0) && (x == 0)) wert =1; // Division durch 0 nicht erlaubt |
else wert= abs((x*1000)/y); |
|
if (wert <=268) //0...0.0,268 entsprechend 0..15 Grad |
{ |
75,7 → 76,7 |
// sinus Funktion: Eingabewert Winkel in Grad, Rueckgabe =sin(winkel)*1000 |
signed int sin_i(signed int winkel) |
{ |
short int m; |
short int m,n; |
|
if (abs(winkel) >=360) winkel = winkel % 360; |
if (winkel < 0) |
84,14 → 85,23 |
winkel = abs(winkel); |
} |
else m = +1; |
|
n =1; |
|
// Quadranten auswerten |
if ((winkel > 90 ) && (winkel <= 180)) winkel = winkel - 90; |
else if ((winkel > 180 ) && (winkel <= 270)) winkel = winkel - 180; |
else if ((winkel > 270) && (winkel <= 360)) winkel = winkel - 270; |
if ((winkel > 90 ) && (winkel <= 180)) winkel = 180 - winkel; |
else if ((winkel > 180 ) && (winkel <= 270)) |
{ |
winkel = winkel -180; |
n = -1; |
} |
else if ((winkel > 270) && (winkel <= 360)) |
{ |
winkel = 360 - winkel; |
n = -1; |
} |
// else //0 - 90 Grad |
|
winkel = pgm_read_word(&pgm_sinus[winkel]); |
return (winkel*m); |
return (winkel*m*n); |
} |
|