code: Use std::numbers::pi
This commit is contained in:
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
constexpr float PI = 3.14159265f;
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct Rectangle {
|
struct Rectangle {
|
||||||
T left{};
|
T left{};
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <numbers>
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "common/quaternion.h"
|
#include "common/quaternion.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
@ -46,7 +47,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
tilt_direction = mouse_move.Cast<float>();
|
tilt_direction = mouse_move.Cast<float>();
|
||||||
tilt_angle = std::clamp(tilt_direction.Normalize() * sensitivity, 0.0f,
|
tilt_angle = std::clamp(tilt_direction.Normalize() * sensitivity, 0.0f,
|
||||||
Common::PI * this->tilt_clamp / 180.0f);
|
std::numbers::pi_v<float> * this->tilt_clamp / 180.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ private:
|
|||||||
|
|
||||||
// Find the angular rate vector in world space
|
// Find the angular rate vector in world space
|
||||||
auto angular_rate = ((q - old_q) * inv_q).xyz * 2;
|
auto angular_rate = ((q - old_q) * inv_q).xyz * 2;
|
||||||
angular_rate *= 1000 / update_millisecond / Common::PI * 180;
|
angular_rate *= 1000 / update_millisecond / std::numbers::pi_v<float> * 180;
|
||||||
|
|
||||||
// Transform the two vectors from world space to 3DS space
|
// Transform the two vectors from world space to 3DS space
|
||||||
gravity = QuaternionRotate(inv_q, gravity);
|
gravity = QuaternionRotate(inv_q, gravity);
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <numbers>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "common/param_package.h"
|
#include "common/param_package.h"
|
||||||
@ -597,9 +597,10 @@ void SDLState::HandleGameControllerEvent(const SDL_Event& event) {
|
|||||||
event.csensor.data[2] / SDL_STANDARD_GRAVITY);
|
event.csensor.data[2] / SDL_STANDARD_GRAVITY);
|
||||||
break;
|
break;
|
||||||
case SDL_SENSOR_GYRO:
|
case SDL_SENSOR_GYRO:
|
||||||
joystick->SetGyro(-event.csensor.data[0] * (180.0f / Common::PI),
|
using namespace std::numbers;
|
||||||
event.csensor.data[1] * (180.0f / Common::PI),
|
joystick->SetGyro(-event.csensor.data[0] * (180.0f / pi),
|
||||||
-event.csensor.data[2] * (180.0f / Common::PI));
|
event.csensor.data[1] * (180.0f / pi),
|
||||||
|
-event.csensor.data[2] * (180.0f / pi));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user