Add Horizontal to vertical FOV convert and vice versa
This commit is contained in:
@@ -7,11 +7,19 @@
|
||||
#include "Maths.hpp"
|
||||
#include <cmath>
|
||||
|
||||
float Maths::FOVHToV(float fovH, float aspect) {
|
||||
return 2.0f * std::atan(std::tan(fovH * 0.5f * (M_PI / 180.0f)) / aspect) * (180.0f / M_PI);
|
||||
}
|
||||
|
||||
float Maths::FOVVToH(float fovV, float aspect) {
|
||||
return 2.0f * std::atan(std::tan(fovV * 0.5f * (M_PI / 180.0f)) * aspect) * (180.0f / M_PI);
|
||||
}
|
||||
|
||||
double Maths::DegreesToRadians(double degrees) {
|
||||
return degrees * M_PI / 180.0;
|
||||
}
|
||||
|
||||
// Convertit des radians en degrés
|
||||
// Converts radians in degree
|
||||
double Maths::RadiansToDegrees(double radians) {
|
||||
return radians * 180.0 / M_PI;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ class Maths
|
||||
public:
|
||||
// Compute new horizontal FOV based on native and target aspect ratio
|
||||
static double CompensateHorizontalFOV(const double baseHorizontalFOVDeg, const double baseAspectRatio, const double targetAspectRatio);
|
||||
// Compute FOV horizontal to vertical based on aspect ratio
|
||||
static float FOVHToV(float fovH, float aspect);
|
||||
// Compute FOV vertical to horizontal based on aspect ratio
|
||||
static float FOVVToH(float fovV, float aspect);
|
||||
|
||||
private:
|
||||
static double DegreesToRadians(double degrees);
|
||||
|
||||
Reference in New Issue
Block a user