FixedPoint.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. #include <math.h>
  19. #include "QuickMath.h"
  20. #include "FixedPoint.h"
  21. RFixedS32 fpSINQ[csNumRotSteps],fpCOSQ[csNumRotSteps];
  22. void InitTrigFP() // fixed point
  23. {
  24. short i;
  25. double rad;
  26. const double cdStepsToRad =
  27. rspPI * 2.0 / double(csNumRotSteps);
  28. for (i=0;i<csNumRotSteps;i++)
  29. {
  30. rad = (double)i * cdStepsToRad;
  31. rspfpSetValue(fpSINQ[i],SINQ[i]);
  32. rspfpSetValue(fpCOSQ[i],COSQ[i]);
  33. }
  34. }
  35. // Auto init:
  36. RQuickTrig dummyRQuickTrig;
  37. long RInitNum::OneOver[NUM_ONEOVER_FP32];
  38. RInitNum::RInitNum()
  39. {
  40. // Populate the oneOver array:
  41. OneOver[0] = long(2147483647); // error, signed infinity!
  42. OneOver[1] = long(65535); // full numbers!
  43. for (short i=2;i<NUM_ONEOVER_FP32;i++) OneOver[i] = long(65536)/i;
  44. }
  45. RInitNum dummyRInitNum;