38 lines
643 B
C++
38 lines
643 B
C++
#include "emath.h"
|
|
|
|
// Trigonometrische Funktionen
|
|
|
|
float deg2rad(float deg) {
|
|
return (deg/180.0f)*3.1415926535897932384626433f;
|
|
}
|
|
|
|
float rad2deg(float rad) {
|
|
return (rad/3.1415926535897932384626433f)*180.0f;
|
|
}
|
|
|
|
float ssin(float c) {
|
|
int t=(int)c;
|
|
if(t!=c)
|
|
return sin(deg2rad(c));
|
|
t = t % 360;
|
|
if(t<0)
|
|
t = 360 + t;
|
|
switch(t) {
|
|
case 0:
|
|
return 0.0f;
|
|
case 90:
|
|
return 1.0f;
|
|
case 180:
|
|
return 0.0f;
|
|
case 270:
|
|
return -1.0f;
|
|
default:
|
|
// std::cout << "ssin sollte keinen defaultwert zurückliefern. c=" << c << ", t=" << t << std::endl;
|
|
return sin(deg2rad(c));
|
|
}
|
|
}
|
|
|
|
float scos(float c) {
|
|
return ssin(c+90.0f);
|
|
}
|