mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 18:04:14 +08:00
Numeric double cast/comparison
This commit is contained in:
@@ -44,7 +44,7 @@ namespace BlackMisc
|
||||
const QVector3D v1 = coordinate1.normalVector();
|
||||
const QVector3D v2 = coordinate2.normalVector();
|
||||
const float d = earthRadiusMeters * std::atan2(QVector3D::crossProduct(v1, v2).length(), QVector3D::dotProduct(v1, v2));
|
||||
return { d, CLengthUnit::m() };
|
||||
return { static_cast<double>(d), CLengthUnit::m() };
|
||||
}
|
||||
|
||||
CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
||||
@@ -56,17 +56,17 @@ namespace BlackMisc
|
||||
const float sinTheta = std::copysign(cross.length(), QVector3D::dotProduct(cross, coordinate1.normalVector()));
|
||||
const float cosTheta = QVector3D::dotProduct(c1, c2);
|
||||
const float theta = std::atan2(sinTheta, cosTheta);
|
||||
return { theta, CAngleUnit::rad() };
|
||||
return { static_cast<double>(theta), CAngleUnit::rad() };
|
||||
}
|
||||
|
||||
double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
||||
{
|
||||
return coordinate1.normalVector().distanceToPoint(coordinate2.normalVector());
|
||||
return static_cast<double>(coordinate1.normalVector().distanceToPoint(coordinate2.normalVector()));
|
||||
}
|
||||
|
||||
double calculateEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
||||
{
|
||||
return (coordinate1.normalVector() - coordinate2.normalVector()).lengthSquared();
|
||||
return static_cast<double>((coordinate1.normalVector() - coordinate2.normalVector()).lengthSquared());
|
||||
}
|
||||
|
||||
bool ICoordinateGeodetic::equalNormalVectorDouble(const std::array<double, 3> &otherVector) const
|
||||
|
||||
@@ -12,17 +12,18 @@
|
||||
#ifndef BLACKMISC_GEO_COORDINATEGEODETIC_H
|
||||
#define BLACKMISC_GEO_COORDINATEGEODETIC_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
@@ -209,7 +210,7 @@ namespace BlackMisc
|
||||
CCoordinateGeodetic() {}
|
||||
|
||||
//! Constructor by normal vector
|
||||
CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {}
|
||||
CCoordinateGeodetic(const QVector3D &normal) : m_x(static_cast<double>(normal.x())), m_y(static_cast<double>(normal.y())), m_z(static_cast<double>(normal.z())) {}
|
||||
|
||||
//! Constructor by normal vector
|
||||
CCoordinateGeodetic(const std::array<double, 3> &normalVector);
|
||||
@@ -269,7 +270,7 @@ namespace BlackMisc
|
||||
void setGeodeticHeightToNull();
|
||||
|
||||
//! Set normal vector
|
||||
void setNormalVector(const QVector3D &normal) { m_x = normal.x(); m_y = normal.y(); m_z = normal.z(); }
|
||||
void setNormalVector(const QVector3D &normal) { m_x = static_cast<double>(normal.x()); m_y = static_cast<double>(normal.y()); m_z = static_cast<double>(normal.z()); }
|
||||
|
||||
//! Set normal vector
|
||||
void setNormalVector(double x, double y, double z) { m_x = x; m_y = y; m_z = z; }
|
||||
@@ -285,7 +286,7 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
//! Is null?
|
||||
virtual bool isNull() const override { return m_x == 0 && m_y == 0 && m_z == 0; }
|
||||
virtual bool isNull() const override { return Math::CMathUtils::epsilonZeroLimits(m_x) && Math::CMathUtils::epsilonZeroLimits(m_y) && Math::CMathUtils::epsilonZeroLimits(m_z); }
|
||||
|
||||
//! Coordinate by WGS84 position data
|
||||
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const Aviation::CAltitude &geodeticHeight = {});
|
||||
|
||||
Reference in New Issue
Block a user