summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--opentrack-compat/pi-constant.hpp3
-rw-r--r--opentrack-logic/tracker.cpp2
-rw-r--r--opentrack-logic/tracker.h3
-rw-r--r--opentrack/simple-mat.cpp3
-rw-r--r--proto-ft/ftnoir_protocol_ft.cpp3
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp5
-rw-r--r--tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp8
-rw-r--r--tracker-hydra/ftnoir_tracker_hydra.cpp7
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h7
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.h3
-rw-r--r--tracker-pt/point_extractor.h3
-rw-r--r--tracker-rift-025/ftnoir_tracker_rift_025.cpp6
-rw-r--r--tracker-rift-042/ftnoir_tracker_rift_042.cpp6
-rw-r--r--tracker-rift-080/ftnoir_tracker_rift_080.cpp7
-rw-r--r--tracker-test/test.h3
15 files changed, 33 insertions, 36 deletions
diff --git a/opentrack-compat/pi-constant.hpp b/opentrack-compat/pi-constant.hpp
new file mode 100644
index 00000000..52b98a7f
--- /dev/null
+++ b/opentrack-compat/pi-constant.hpp
@@ -0,0 +1,3 @@
+#pragma once
+
+#define OPENTRACK_PI 3.14159265358979323846
diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp
index 10512059..4fcce853 100644
--- a/opentrack-logic/tracker.cpp
+++ b/opentrack-logic/tracker.cpp
@@ -108,7 +108,7 @@ void Tracker::logic()
m(5).opts.invert,
};
- static constexpr double pi = 3.141592653;
+ static constexpr double pi = OPENTRACK_PI;
static constexpr double r2d = 180. / pi;
static constexpr double d2r = pi / 180.;
diff --git a/opentrack-logic/tracker.h b/opentrack-logic/tracker.h
index 1c29fb8d..618de409 100644
--- a/opentrack-logic/tracker.h
+++ b/opentrack-logic/tracker.h
@@ -10,6 +10,7 @@
#include <vector>
+#include "opentrack-compat/pi-constant.hpp"
#include "opentrack-compat/timer.hpp"
#include "opentrack/plugin-support.hpp"
#include "mappings.hpp"
@@ -28,7 +29,7 @@
class Pose
{
private:
- static constexpr double pi = 3.141592653;
+ static constexpr double pi = OPENTRACK_PI;
static constexpr double d2r = pi/180.0;
static constexpr double r2d = 180./pi;
diff --git a/opentrack/simple-mat.cpp b/opentrack/simple-mat.cpp
index 8173f888..b9273fc0 100644
--- a/opentrack/simple-mat.cpp
+++ b/opentrack/simple-mat.cpp
@@ -1,8 +1,9 @@
#include "simple-mat.hpp"
+#include "opentrack-compat/pi-constant.hpp"
namespace euler {
-static constexpr double pi = 3.141592653;
+static constexpr double pi = OPENTRACK_PI;
euler_t rmat_to_euler(const dmat<3, 3>& R)
{
diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp
index d0e89753..fe96db93 100644
--- a/proto-ft/ftnoir_protocol_ft.cpp
+++ b/proto-ft/ftnoir_protocol_ft.cpp
@@ -9,6 +9,7 @@
#include "ftnoir_protocol_ft.h"
#include "csv/csv.h"
#include "opentrack-library-path.h"
+#include "opentrack-compat/pi-constant.hpp"
check_for_first_run FTNoIR_Protocol::runonce_check = check_for_first_run();
@@ -96,7 +97,7 @@ void FTNoIR_Protocol::pose(const double* headpose)
float FTNoIR_Protocol::degrees_to_rads(double degrees)
{
- static constexpr double pi = 3.14159265358979323846;
+ static constexpr double pi = OPENTRACK_PI;
return float(degrees*pi/180);
}
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index de26c420..7e635a85 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -14,6 +14,7 @@
#include <opencv2/calib3d.hpp>
#include "opentrack-compat/camera-names.hpp"
#include "opentrack-compat/sleep.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <QMutexLocker>
#include <QDebug>
@@ -87,7 +88,7 @@ void Tracker::start_tracker(QFrame* videoframe)
layout = layout_;
}
-#define HT_PI 3.1415926535
+#define HT_PI OPENTRACK_PI
void Tracker::getRT(cv::Matx33d& r_, cv::Vec3d& t_)
{
@@ -181,7 +182,7 @@ bool Tracker::open_camera()
void Tracker::set_intrinsics()
{
- static constexpr double pi = 3.1415926f;
+ 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 fov_w = 2.*atan(tan(diag_fov/2.)/sqrt(1. + h/(double)w * h/(double)w));
diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
index 621e601a..9a5697dd 100644
--- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
+++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
@@ -1,13 +1,11 @@
#include "ftnoir_tracker_freepie-udp.h"
#include "opentrack/plugin-api.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <cinttypes>
#include <algorithm>
#include <cmath>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
TrackerImpl::TrackerImpl() : pose { 0,0,0, 0,0,0 }, should_quit(false)
{
@@ -43,7 +41,7 @@ void TrackerImpl::run() {
Mask = flag_Raw | flag_Orient
};
- (void) sock.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
+ sock.bind(QHostAddress::Any, (unsigned short) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
while (!should_quit) {
int order[] = {
@@ -92,7 +90,7 @@ void TrackerImpl::run() {
};
int indices[] = { s.add_yaw, s.add_pitch, s.add_roll };
QMutexLocker foo(&mtx);
- static constexpr double r2d = 180 / M_PI;
+ static constexpr double r2d = 180 / OPENTRACK_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 1e3c1189..33156f85 100644
--- a/tracker-hydra/ftnoir_tracker_hydra.cpp
+++ b/tracker-hydra/ftnoir_tracker_hydra.cpp
@@ -1,6 +1,7 @@
/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
#include "ftnoir_tracker_hydra.h"
#include "opentrack/plugin-api.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <cstdio>
#include <cmath>
#ifdef _WIN32
@@ -9,10 +10,6 @@
#endif
#include <sixense.h>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
Hydra_Tracker::Hydra_Tracker() : should_quit(false) {}
#include <sixense_math.hpp>
@@ -42,7 +39,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/M_PI;
+ static constexpr double r2d = 180/OPENTRACK_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.h b/tracker-pt/ftnoir_tracker_pt.h
index 40f9ad4a..d2f69ac2 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -17,6 +17,7 @@
#include "pt_video_widget.h"
#include "opentrack-compat/timer.hpp"
#include "opentrack/opencv-camera-dialog.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <QThread>
#include <QMutex>
@@ -32,7 +33,7 @@ class TrackerDialog_PT;
// Constantly processes the tracking chain in a separate thread
class Tracker_PT : public QThread, public ITracker, private pt_types
{
- static constexpr double pi = 3.14159265359;
+ static constexpr double pi = OPENTRACK_PI;
Q_OBJECT
friend class camera_dialog;
@@ -76,8 +77,8 @@ private:
volatile bool ever_success;
volatile unsigned char commands;
- static constexpr f rad2deg = f(180/3.14159265);
- //static constexpr float deg2rad = float(3.14159265/180);
+ static constexpr f rad2deg = f(180/OPENTRACK_PI);
+ //static constexpr float deg2rad = float(OPENTRACK_PI/180);
};
class TrackerDll : public Metadata
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h
index 830bf92e..f5256f18 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.h
+++ b/tracker-pt/ftnoir_tracker_pt_settings.h
@@ -8,6 +8,7 @@
#pragma once
+#include "opentrack-compat/pi-constant.hpp"
#include <limits>
#include <opencv2/core.hpp>
@@ -16,7 +17,7 @@ struct pt_types
using f = double;
static constexpr f eps = std::numeric_limits<f>::epsilon();
- static constexpr f pi = f(3.14159265358979323846);
+ static constexpr f pi = f(OPENTRACK_PI);
template<int n> using vec = cv::Vec<f, n>;
using vec2 = vec<2>;
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 52b4cb32..16740b91 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -13,6 +13,7 @@
#include <opencv2/imgproc/imgproc.hpp>
#include "ftnoir_tracker_pt_settings.h"
+#include "opentrack-compat/pi-constant.hpp"
#include <QMutex>
#include <vector>
@@ -29,7 +30,7 @@ public:
settings_pt s;
private:
- static constexpr double pi = 3.14159265359;
+ static constexpr double pi = OPENTRACK_PI;
std::vector<vec2> points;
QMutex mtx;
diff --git a/tracker-rift-025/ftnoir_tracker_rift_025.cpp b/tracker-rift-025/ftnoir_tracker_rift_025.cpp
index aab8d530..d39599a9 100644
--- a/tracker-rift-025/ftnoir_tracker_rift_025.cpp
+++ b/tracker-rift-025/ftnoir_tracker_rift_025.cpp
@@ -2,12 +2,10 @@
#include "ftnoir_tracker_rift_025.h"
#include "opentrack/plugin-api.hpp"
#include "OVR.h"
+#include "opentrack-compat/pi-constant.hpp"
#include <cstdio>
#include <cmath>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
using namespace OVR;
@@ -87,7 +85,7 @@ void Rift_Tracker::data(double *data)
old_yaw = yaw_;
}
- static constexpr double r2d = 180 / M_PI;
+ static constexpr double r2d = 180 / OPENTRACK_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 853dfcf9..749a927f 100644
--- a/tracker-rift-042/ftnoir_tracker_rift_042.cpp
+++ b/tracker-rift-042/ftnoir_tracker_rift_042.cpp
@@ -7,10 +7,6 @@
#include <cstring>
#include <cmath>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
using namespace OVR;
Rift_Tracker::Rift_Tracker() : old_yaw(0), hmd(nullptr)
@@ -66,7 +62,7 @@ void Rift_Tracker::data(double *data)
yaw_ += s.constant_drift;
old_yaw = yaw_;
}
- static constexpr double d2r = 180 / M_PI;
+ static constexpr double d2r = 180 / OPENTRACK_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 c1a07407..94c8dc41 100644
--- a/tracker-rift-080/ftnoir_tracker_rift_080.cpp
+++ b/tracker-rift-080/ftnoir_tracker_rift_080.cpp
@@ -4,12 +4,9 @@
#include "OVR_CAPI.h"
#include "Extras/OVR_Math.h"
#include "OVR_CAPI_0_8_0.h"
+#include "opentrack-compat/pi-constant.hpp"
#include <cstdio>
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
using namespace OVR;
Rift_Tracker::Rift_Tracker() : old_yaw(0), hmd(nullptr)
@@ -63,7 +60,7 @@ void Rift_Tracker::data(double *data)
yaw_ += s.constant_drift;
old_yaw = yaw_;
}
- static constexpr double d2r = 180 / M_PI;
+ static constexpr double d2r = 180 / OPENTRACK_PI;
data[Yaw] = yaw_ * -d2r;
data[Pitch] = double(pitch) * d2r;
data[Roll] = double(roll) * d2r;
diff --git a/tracker-test/test.h b/tracker-test/test.h
index 500b28f4..afb11f6f 100644
--- a/tracker-test/test.h
+++ b/tracker-test/test.h
@@ -2,6 +2,7 @@
#include "ui_test.h"
#include "opentrack/plugin-api.hpp"
#include "opentrack-compat/timer.hpp"
+#include "opentrack-compat/pi-constant.hpp"
class FTNoIR_Tracker : public ITracker
{
@@ -12,7 +13,7 @@ public:
void data(double *data) override;
private:
- static constexpr double pi = 3.14159265358979323846;
+ static constexpr double pi = OPENTRACK_PI;
static constexpr double r2d = 180 / pi;
static constexpr double d2r = pi / 180;