mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Missing include, fixing missing M_PI
Using the little "PI = std::acos(-1);" trick to avoid include issues
This commit is contained in:
committed by
Roland Winklmeier
parent
da94b6c0df
commit
75c481228f
@@ -27,6 +27,7 @@
|
|||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QtMath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -214,7 +215,6 @@ namespace BlackMisc
|
|||||||
(void)QT_TRANSLATE_NOOP("CMeasurementUnit", "-%L1 %L2 %L3");
|
(void)QT_TRANSLATE_NOOP("CMeasurementUnit", "-%L1 %L2 %L3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Sexagesimal degree (degrees, minutes, decimal minutes)
|
//! Sexagesimal degree (degrees, minutes, decimal minutes)
|
||||||
static CAngleUnit sexagesimalDegMin()
|
static CAngleUnit sexagesimalDegMin()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,33 +7,34 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//! \cond PRIVATE
|
||||||
|
|
||||||
#include "navdatareference.h"
|
#include "navdatareference.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace XSwiftBus
|
namespace XSwiftBus
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Converts degree to radian
|
|
||||||
inline double degreeToRadian(double angle)
|
inline double degreeToRadian(double angle)
|
||||||
{
|
{
|
||||||
return M_PI * angle / 180.0;
|
static const double PI = acos(-1);
|
||||||
|
return PI * angle / 180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns the great circle distance between to nav data references
|
|
||||||
double calculateGreatCircleDistance(const CNavDataReference &a, const CNavDataReference &b)
|
double calculateGreatCircleDistance(const CNavDataReference &a, const CNavDataReference &b)
|
||||||
{
|
{
|
||||||
const static double c_earthRadiusKm = 6372.8;
|
const static double c_earthRadiusKm = 6372.8;
|
||||||
|
|
||||||
double latRad1 = degreeToRadian(a.latitude());
|
const double latRad1 = degreeToRadian(a.latitude());
|
||||||
double latRad2 = degreeToRadian(b.latitude());
|
const double latRad2 = degreeToRadian(b.latitude());
|
||||||
double lonRad1 = degreeToRadian(a.longitude());
|
const double lonRad1 = degreeToRadian(a.longitude());
|
||||||
double lonRad2 = degreeToRadian(b.longitude());
|
const double lonRad2 = degreeToRadian(b.longitude());
|
||||||
|
|
||||||
double diffLa = latRad2 - latRad1;
|
const double diffLa = latRad2 - latRad1;
|
||||||
double doffLo = lonRad2 - lonRad1;
|
const double doffLo = lonRad2 - lonRad1;
|
||||||
|
|
||||||
double computation = asin(sqrt(sin(diffLa / 2) * sin(diffLa / 2) + cos(latRad1) * cos(latRad2) * sin(doffLo / 2) * sin(doffLo / 2)));
|
const double computation = asin(sqrt(sin(diffLa / 2) * sin(diffLa / 2) + cos(latRad1) * cos(latRad2) * sin(doffLo / 2) * sin(doffLo / 2)));
|
||||||
return 2 * c_earthRadiusKm * computation;
|
return 2 * c_earthRadiusKm * computation;
|
||||||
}
|
}
|
||||||
|
} // ns
|
||||||
|
|
||||||
}
|
//! \endcond
|
||||||
|
|||||||
@@ -674,9 +674,10 @@ namespace XSwiftBus
|
|||||||
// Now calculate where the camera should be positioned to be 200
|
// Now calculate where the camera should be positioned to be 200
|
||||||
// meters from the plane and pointing at the plane at the pitch and
|
// meters from the plane and pointing at the plane at the pitch and
|
||||||
// heading we wanted above.
|
// heading we wanted above.
|
||||||
double dx = -50.0 * sin(heading * M_PI / 180.0);
|
static const double PI = std::acos(-1);
|
||||||
double dz = 50.0 * cos(heading * M_PI / 180.0);
|
double dx = -50.0 * sin(heading * PI / 180.0);
|
||||||
double dy = -50.0 * tan(pitch * M_PI / 180.0);
|
double dz = 50.0 * cos(heading * PI / 180.0);
|
||||||
|
double dy = -50.0 * tan(pitch * PI / 180.0);
|
||||||
|
|
||||||
auto planeIt = traffic->m_planesByCallsign.find(traffic->m_planeViewCallsign);
|
auto planeIt = traffic->m_planesByCallsign.find(traffic->m_planeViewCallsign);
|
||||||
if (planeIt == traffic->m_planesByCallsign.end()) { return 0; }
|
if (planeIt == traffic->m_planesByCallsign.end()) { return 0; }
|
||||||
|
|||||||
Reference in New Issue
Block a user