diff options
| -rw-r--r-- | compat/pi-constant.hpp | 3 | ||||
| -rw-r--r-- | logic/simple-mat.cpp | 1 | ||||
| -rw-r--r-- | logic/tracker.cpp | 3 | ||||
| -rw-r--r-- | logic/tracker.h | 7 | ||||
| -rw-r--r-- | pose-widget/glwidget.cpp | 3 | ||||
| -rw-r--r-- | proto-ft/ftnoir_protocol_ft.cpp | 6 | ||||
| -rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 6 | ||||
| -rw-r--r-- | tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp | 3 | ||||
| -rw-r--r-- | tracker-hydra/ftnoir_tracker_hydra.cpp | 3 | ||||
| -rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 4 | ||||
| -rw-r--r-- | tracker-pt/ftnoir_tracker_pt.h | 6 | ||||
| -rw-r--r-- | tracker-pt/ftnoir_tracker_pt_settings.cpp | 1 | ||||
| -rw-r--r-- | tracker-pt/ftnoir_tracker_pt_settings.h | 4 | ||||
| -rw-r--r-- | tracker-pt/point_extractor.cpp | 4 | ||||
| -rw-r--r-- | tracker-pt/point_extractor.h | 1 | ||||
| -rw-r--r-- | tracker-pt/point_tracker.cpp | 9 | ||||
| -rw-r--r-- | tracker-rift-025/ftnoir_tracker_rift_025.cpp | 3 | ||||
| -rw-r--r-- | tracker-rift-042/ftnoir_tracker_rift_042.cpp | 3 | ||||
| -rw-r--r-- | tracker-rift-080/ftnoir_tracker_rift_080.cpp | 4 | ||||
| -rw-r--r-- | tracker-test/test.cpp | 7 | ||||
| -rw-r--r-- | tracker-test/test.h | 8 | 
21 files changed, 34 insertions, 55 deletions
| diff --git a/compat/pi-constant.hpp b/compat/pi-constant.hpp deleted file mode 100644 index 52b98a7f..00000000 --- a/compat/pi-constant.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#define OPENTRACK_PI 3.14159265358979323846 diff --git a/logic/simple-mat.cpp b/logic/simple-mat.cpp index 24a2d69e..57571f9e 100644 --- a/logic/simple-mat.cpp +++ b/logic/simple-mat.cpp @@ -1,5 +1,4 @@  #include "simple-mat.hpp" -#include "compat/pi-constant.hpp"  #include <cmath>  namespace euler { diff --git a/logic/tracker.cpp b/logic/tracker.cpp index 3a8df56e..f404e8e0 100644 --- a/logic/tracker.cpp +++ b/logic/tracker.cpp @@ -24,6 +24,9 @@  #   include <windows.h>  #endif +constexpr double Tracker::r2d; +constexpr double Tracker::d2r; +  Tracker::Tracker(Mappings &m, SelectedLibraries &libs, TrackLogger &logger) :      m(m),      libs(libs), diff --git a/logic/tracker.h b/logic/tracker.h index 9c100ea7..1546d910 100644 --- a/logic/tracker.h +++ b/logic/tracker.h @@ -10,7 +10,6 @@  #include <vector> -#include "compat/pi-constant.hpp"  #include "compat/timer.hpp"  #include "api/plugin-support.hpp"  #include "mappings.hpp" @@ -26,6 +25,7 @@  #include <QThread>  #include <atomic> +#include <cmath>  #include "export.hpp" @@ -121,9 +121,8 @@ private:      void t_compensate(const rmat& rmat, const euler_t& ypr, euler_t& output, bool rz);      void run() override; -    static constexpr double pi = OPENTRACK_PI; -    static constexpr double r2d = 180. / OPENTRACK_PI; -    static constexpr double d2r = OPENTRACK_PI / 180.; +    static constexpr double r2d = 180. / M_PI; +    static constexpr double d2r = M_PI / 180.;      // note: float exponent base is 2      static constexpr double c_mult = 4; diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index a2a76726..4b5e9731 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -7,7 +7,6 @@  #include "glwidget.h"  #include "api/is-window-visible.hpp" -#include "compat/pi-constant.hpp"  #include <cmath>  #include <algorithm>  #include <QPainter> @@ -52,7 +51,7 @@ void GLWidget::rotateBy_real(double xAngle, double yAngle, double zAngle, double      using std::sin;      using std::cos; -    static constexpr double d2r = OPENTRACK_PI / 180; +    static constexpr double d2r = M_PI / 180;      translation = vec3(x, y, z); diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 6a2d1cb2..8ac3ba75 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -9,7 +9,8 @@  #include "ftnoir_protocol_ft.h"  #include "csv/csv.h"  #include "opentrack-library-path.h" -#include "compat/pi-constant.hpp" + +#include <cmath>  check_for_first_run FTNoIR_Protocol::runonce_check = check_for_first_run(); @@ -96,8 +97,7 @@ void FTNoIR_Protocol::pose(const double* headpose)  float FTNoIR_Protocol::degrees_to_rads(double degrees)  { -    static constexpr double pi = OPENTRACK_PI; -    return float(degrees*pi/180); +    return float(degrees*M_PI/180);  }  void FTNoIR_Protocol::start_tirviews() diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 81a2e176..18e6a9bf 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -9,7 +9,6 @@  #include "api/plugin-api.hpp"  #include "compat/camera-names.hpp"  #include "compat/sleep.hpp" -#include "compat/pi-constant.hpp"  #include "cv/video-property-page.hpp"  #include <opencv2/core.hpp> @@ -89,7 +88,7 @@ void Tracker::start_tracker(QFrame* videoframe)      layout = layout_;  } -#define HT_PI OPENTRACK_PI +#define HT_PI M_PI  void Tracker::getRT(cv::Matx33d& r_, cv::Vec3d& t_)  { @@ -186,9 +185,8 @@ bool Tracker::open_camera()  void Tracker::set_intrinsics()  { -    static constexpr double pi = OPENTRACK_PI;      const int w = grayscale.cols, h = grayscale.rows; -    const double diag_fov = static_cast<int>(s.fov) * pi / 180.; +    const double diag_fov = static_cast<int>(s.fov) * M_PI / 180.;      const double fov_w = 2.*atan(tan(diag_fov/2.)/sqrt(1. + h/(double)w * h/(double)w));      const double fov_h = 2.*atan(tan(diag_fov/2.)/sqrt(1. + w/(double)h * w/(double)h));      const double focal_length_w = .5 * w / tan(.5 * fov_w); diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp index 800428aa..d6d53803 100644 --- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -1,6 +1,5 @@  #include "ftnoir_tracker_freepie-udp.h"  #include "api/plugin-api.hpp" -#include "compat/pi-constant.hpp"  #include <cinttypes>  #include <algorithm> @@ -90,7 +89,7 @@ void TrackerImpl::run() {              };              int indices[] = { s.add_yaw, s.add_pitch, s.add_roll };              QMutexLocker foo(&mtx); -            static constexpr double r2d = 180 / OPENTRACK_PI; +            static constexpr double r2d = 180 / M_PI;              for (int i = 0; i < 3; i++)              {                  int val = 0; diff --git a/tracker-hydra/ftnoir_tracker_hydra.cpp b/tracker-hydra/ftnoir_tracker_hydra.cpp index 6b52153f..809f2fba 100644 --- a/tracker-hydra/ftnoir_tracker_hydra.cpp +++ b/tracker-hydra/ftnoir_tracker_hydra.cpp @@ -1,7 +1,6 @@  /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */  #include "ftnoir_tracker_hydra.h"  #include "api/plugin-api.hpp" -#include "compat/pi-constant.hpp"  #include <cstdio>  #include <cmath>  #ifdef _WIN32 @@ -39,7 +38,7 @@ void Hydra_Tracker::data(double *data)      data[TX] = double(acd.controllers[0].pos[0])/50;      data[TY] = double(acd.controllers[0].pos[1])/50;      data[TZ] = double(acd.controllers[0].pos[2])/50; -    static constexpr double r2d = 180/OPENTRACK_PI; +    static constexpr double r2d = 180/M_PI;      data[Yaw] = double(ypr[0]) * r2d;      data[Pitch] = double(ypr[1]) * r2d;      data[Roll] = double(ypr[2]) * r2d; diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 20327020..ce19d592 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -18,8 +18,6 @@  //#define PT_PERF_LOG	//log performance -constexpr f Tracker_PT::pi; -  //-----------------------------------------------------------------------------  Tracker_PT::Tracker_PT() :        video_widget(nullptr), @@ -72,7 +70,7 @@ bool Tracker_PT::get_focal_length(f& ret)          const int w = info.res_x, h = info.res_y;          const double diag = sqrt(1. + h/(double)w * h/(double)w); -        const double diag_fov = static_cast<int>(s.fov) * pi / 180.; +        const double diag_fov = static_cast<int>(s.fov) * M_PI / 180.;          const double fov = 2.*atan(tan(diag_fov/2.0)/diag);          ret = .5 / tan(.5 * fov);          return true; diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index 047aedda..513c9b2c 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -33,8 +33,6 @@ class TrackerDialog_PT;  // Constantly processes the tracking chain in a separate thread  class Tracker_PT : public QThread, public ITracker  { -    static constexpr f pi = constants::pi; -      Q_OBJECT      friend class camera_dialog;      friend class TrackerDialog_PT; @@ -80,8 +78,8 @@ private:      volatile unsigned char commands;      volatile bool ever_success; -    static constexpr f rad2deg = f(180/OPENTRACK_PI); -    //static constexpr float deg2rad = float(OPENTRACK_PI/180); +    static constexpr f rad2deg = f(180/M_PI); +    //static constexpr float deg2rad = float(M_PI/180);  };  class TrackerDll : public Metadata diff --git a/tracker-pt/ftnoir_tracker_pt_settings.cpp b/tracker-pt/ftnoir_tracker_pt_settings.cpp index e685960c..5d4b598f 100644 --- a/tracker-pt/ftnoir_tracker_pt_settings.cpp +++ b/tracker-pt/ftnoir_tracker_pt_settings.cpp @@ -3,6 +3,5 @@  namespace pt_types {  constexpr f constants::eps; -constexpr f constants::pi;  } diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h index b3f9e402..e742fbbc 100644 --- a/tracker-pt/ftnoir_tracker_pt_settings.h +++ b/tracker-pt/ftnoir_tracker_pt_settings.h @@ -8,10 +8,11 @@  #pragma once -#include "compat/pi-constant.hpp"  #include <limits>  #include <opencv2/core.hpp> +#include <cmath> +  namespace pt_types {      using f = double; @@ -19,7 +20,6 @@ namespace pt_types {      {          constants() = delete;          static constexpr f eps = std::numeric_limits<f>::epsilon(); -        static constexpr f pi = OPENTRACK_PI;      };      template<int n> using vec = cv::Vec<f, n>; diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index 6411fcef..0fd177e0 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -19,8 +19,6 @@  #include <algorithm>  #include <cinttypes> -constexpr double PointExtractor::pi; -  PointExtractor::PointExtractor()  {      blobs.reserve(max_blobs); @@ -132,7 +130,7 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector<vec2>& points)              }              if (m00 > 0)              { -                const double radius = sqrt(cnt / pi); +                const double radius = sqrt(cnt / M_PI);                  if (radius > region_size_max || radius < region_size_min)                      continue;                  const double norm = double(m00); diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h index 5ebd8056..9ac2d695 100644 --- a/tracker-pt/point_extractor.h +++ b/tracker-pt/point_extractor.h @@ -29,7 +29,6 @@ public:      settings_pt s;  private: -    static constexpr double pi = constants::pi;      static constexpr int max_blobs = 16;      cv::Mat frame_gray; diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 4c7ca4be..24edca45 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -207,9 +207,6 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc      // In every iteration step the rotation closer to R_expected is taken      mat33 R_expected = mat33::eye(); -    static constexpr f pi = constants::pi; -    static constexpr f eps = constants::eps; -      // initial pose = last (predicted) pose      vec3 k;      get_row(R_expected, 2, k); @@ -263,14 +260,14 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc          // CAVEAT don't change to comparison with an epsilon -sh 20160423          if (JJ0 == II0) {              rho = sqrt(fabs(2*IJ0)); -            theta = -pi/4; +            theta = -M_PI/4;              if (IJ0<0) theta *= -1;          }          else {              rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 ));              theta = atan( -2*IJ0 / (JJ0-II0) );              // avoid branch misprediction -            theta += (JJ0 - II0 < 0) * pi; +            theta += (JJ0 - II0 < 0) * M_PI;              theta *= f(.5);          } @@ -313,7 +310,7 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc          // check for convergence condition          const f delta = fabs(epsilon_1 - old_epsilon_1) + fabs(epsilon_2 - old_epsilon_2); -        if (!(delta > eps)) +        if (!(delta > constants::eps))              break;          old_epsilon_1 = epsilon_1; diff --git a/tracker-rift-025/ftnoir_tracker_rift_025.cpp b/tracker-rift-025/ftnoir_tracker_rift_025.cpp index 51eed855..dcb97fc5 100644 --- a/tracker-rift-025/ftnoir_tracker_rift_025.cpp +++ b/tracker-rift-025/ftnoir_tracker_rift_025.cpp @@ -1,7 +1,6 @@  /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */  #include "ftnoir_tracker_rift_025.h"  #include "api/plugin-api.hpp" -#include "compat/pi-constant.hpp"  #include <OVR.h>  #include <cstdio>  #include <cmath> @@ -85,7 +84,7 @@ void Rift_Tracker::data(double *data)              old_yaw = yaw_;          } -        static constexpr double r2d = 180 / OPENTRACK_PI; +        static constexpr double r2d = 180 / M_PI;          data[Yaw] = yaw_ * r2d;          data[Pitch] = double(pitch) * r2d; diff --git a/tracker-rift-042/ftnoir_tracker_rift_042.cpp b/tracker-rift-042/ftnoir_tracker_rift_042.cpp index 6107dc8d..c868eee8 100644 --- a/tracker-rift-042/ftnoir_tracker_rift_042.cpp +++ b/tracker-rift-042/ftnoir_tracker_rift_042.cpp @@ -1,7 +1,6 @@  /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */  #include "ftnoir_tracker_rift_042.h"  #include "api/plugin-api.hpp" -#include "compat/pi-constant.hpp"  #include <QString> @@ -68,7 +67,7 @@ void Rift_Tracker::data(double *data)                      yaw_ += s.constant_drift;                  old_yaw = yaw_;              } -            static constexpr double d2r = 180 / OPENTRACK_PI; +            static constexpr double d2r = 180 / M_PI;              data[Yaw] = yaw_ * -d2r;              data[Pitch] = double(pitch) * d2r;              data[Roll] = double(roll) * d2r; diff --git a/tracker-rift-080/ftnoir_tracker_rift_080.cpp b/tracker-rift-080/ftnoir_tracker_rift_080.cpp index f8091613..8522a540 100644 --- a/tracker-rift-080/ftnoir_tracker_rift_080.cpp +++ b/tracker-rift-080/ftnoir_tracker_rift_080.cpp @@ -1,7 +1,6 @@  /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */  #include "ftnoir_tracker_rift_080.h"  #include "api/plugin-api.hpp" -#include "compat/pi-constant.hpp"  #include <QString> @@ -10,6 +9,7 @@  #include <OVR_CAPI_0_8_0.h>  #include <cstdio> +#include <cmath>  using namespace OVR; @@ -79,7 +79,7 @@ void Rift_Tracker::data(double *data)                      yaw_ += s.constant_drift;                  old_yaw = yaw_;              } -            static constexpr double d2r = 180 / OPENTRACK_PI; +            static constexpr double d2r = 180 / M_PI;              data[Yaw] = yaw_                   * -d2r;              data[Pitch] = double(pitch)        *  d2r;              data[Roll] = double(roll)          *  d2r; diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp index 3e0db547..9ffdd366 100644 --- a/tracker-test/test.cpp +++ b/tracker-test/test.cpp @@ -56,17 +56,16 @@ void FTNoIR_Tracker::data(double *data)  #endif          for (int i = 0; i < 6; i++)          { -            double x = fmod(last_x[i] + incr[i] * d2r * dt, -                            2 * pi); +            double x = fmod(last_x[i] + incr[i] * d2r * dt, 2 * M_PI);              last_x[i] = x;              if (i >= 3)              {  #ifdef DISCONTINUITY                  if (x > pi + pi/2) -                    x -= pi; +                    x -= M_PI;                  else if (x > pi/2 && x < pi) -                    x += pi; +                    x += M_PI;  #endif                  data[i] = sin(x) * 180; diff --git a/tracker-test/test.h b/tracker-test/test.h index 786d7705..acaee67d 100644 --- a/tracker-test/test.h +++ b/tracker-test/test.h @@ -2,7 +2,8 @@  #include "ui_test.h"  #include "api/plugin-api.hpp"  #include "compat/timer.hpp" -#include "compat/pi-constant.hpp" + +#include <cmath>  class FTNoIR_Tracker : public ITracker  { @@ -13,9 +14,8 @@ public:      void data(double *data) override;  private: -    static constexpr double pi = OPENTRACK_PI; -    static constexpr double r2d = 180 / pi; -    static constexpr double d2r = pi / 180; +    static constexpr double r2d = 180 / M_PI; +    static constexpr double d2r = M_PI / 180;      static const double incr[6];      double last_x[6]; | 
