Small OpenGL based c++ rendering library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

emath.cpp 578B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "emath.h"
  2. namespace segl {
  3. // Trigonometrische Funktionen
  4. float deg2rad(float deg) {
  5. return (deg/180.0f)*3.1415926535897932384626433f;
  6. }
  7. float rad2deg(float rad) {
  8. return (rad/3.1415926535897932384626433f)*180.0f;
  9. }
  10. float ssin(float c) {
  11. int t=(int)c;
  12. if(t!=c)
  13. return sin(deg2rad(c));
  14. t = t % 360;
  15. if(t<0)
  16. t = 360 + t;
  17. switch(t) {
  18. case 0:
  19. return 0.0f;
  20. case 90:
  21. return 1.0f;
  22. case 180:
  23. return 0.0f;
  24. case 270:
  25. return -1.0f;
  26. default:
  27. return sin(deg2rad(c));
  28. }
  29. }
  30. float scos(float c) {
  31. return ssin(c+90.0f);
  32. }
  33. } // namespace segl