mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Had to withdraw 3Vector3D, since they store values internally as float (idiotic design). Hence qreal will be dropped. Started with Unit tests.
This commit is contained in:
@@ -14,40 +14,40 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
BlackMisc::CApplicationContext myApplicationContext;
|
||||
|
||||
QElapsedTimer timer;
|
||||
qint64 duration;
|
||||
|
||||
QElapsedTimer timer;
|
||||
qint64 duration;
|
||||
|
||||
double lat = 27.999999, lon = 86.999999, h = 8820.999999; // Mt Everest
|
||||
|
||||
BlackCore::CEcef mediumvec;
|
||||
BlackCore::CVectorGeo startVec(lat, lon, h);
|
||||
startVec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
BlackCore::CVectorGeo endVec;
|
||||
|
||||
timer.start();
|
||||
mediumvec = startVec.toCartesian();
|
||||
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
mediumvec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
timer.restart();
|
||||
endVec = mediumvec.toGeodetic();
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
endVec.print();
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
BlackCore::CEcef mediumvec;
|
||||
BlackCore::CVectorGeo startVec(lat, lon, h);
|
||||
startVec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
BlackCore::CVectorGeo endVec;
|
||||
|
||||
timer.start();
|
||||
mediumvec = startVec.toCartesian();
|
||||
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
mediumvec.print();
|
||||
|
||||
cout << std::endl;
|
||||
cout << std::endl;
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
timer.restart();
|
||||
endVec = mediumvec.toGeodetic();
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
endVec.print();
|
||||
|
||||
cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl << std::endl;
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "samplesvectormatrix.h"
|
||||
#include "samplesgeo.h"
|
||||
#include "samplesgeodetictoecef.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
/*!
|
||||
@@ -13,5 +14,6 @@ int main(int argc, char *argv[])
|
||||
QCoreApplication a(argc, argv);
|
||||
BlackMiscTest::CSamplesVectorMatrix::samples();
|
||||
BlackMiscTest::CSamplesGeo::samples();
|
||||
BlackMiscTest::CSamplesGeodeticToEcef::samples();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ DESTDIR = ../../bin
|
||||
|
||||
SOURCES += main.cpp \
|
||||
samplesvectormatrix.cpp \
|
||||
samplesgeo.cpp
|
||||
samplesgeo.cpp \
|
||||
samplesgeodetictoecef.cpp
|
||||
|
||||
HEADERS += \
|
||||
samplesvectormatrix.h \
|
||||
samplesgeo.h
|
||||
samplesgeo.h \
|
||||
samplesgeodetictoecef.h
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "samplesgeo.h"
|
||||
|
||||
using namespace BlackMisc::Geo;
|
||||
|
||||
44
samples/blackmiscvectorgeo/samplesgeodetictoecef.cpp
Normal file
44
samples/blackmiscvectorgeo/samplesgeodetictoecef.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "samplesgeodetictoecef.h"
|
||||
#include <QElapsedTimer>
|
||||
|
||||
using namespace BlackMisc::Geo;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
int CSamplesGeodeticToEcef::samples()
|
||||
{
|
||||
|
||||
QElapsedTimer timer;
|
||||
qint64 duration;
|
||||
|
||||
double lat = 27.999999, lon = 86.999999, h = 8820.999999; // Mt Everest
|
||||
CCoordinateGeodetic startVec(lat, lon, h);
|
||||
std::cout << startVec << std::endl;
|
||||
|
||||
timer.start();
|
||||
CCoordinateEcef mediumvec = CCoordinateTransformation::toEcef(startVec);
|
||||
duration = timer.nsecsElapsed();
|
||||
std::cout << mediumvec << " ";
|
||||
std::cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl;
|
||||
|
||||
timer.restart();
|
||||
CCoordinateGeodetic endVec = CCoordinateTransformation::toGeodetic(mediumvec);
|
||||
duration = timer.nsecsElapsed();
|
||||
|
||||
std::cout << endVec << " ";
|
||||
std::cout << "Needed " << duration << " nanoseconds for the calculation!" << std::endl;
|
||||
|
||||
std::cout << "-----------------------------------------------" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
32
samples/blackmiscvectorgeo/samplesgeodetictoecef.h
Normal file
32
samples/blackmiscvectorgeo/samplesgeodetictoecef.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKMISCTEST_SAMPLESGEO2ECEF_H
|
||||
#define BLACKMISCTEST_SAMPLESGEO2ECEF_H
|
||||
#include "blackmisc/coordinatetransformation.h"
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Samples for vector / matrix
|
||||
*/
|
||||
class CSamplesGeodeticToEcef
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Run the samples
|
||||
*/
|
||||
static int samples();
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief Avoid init
|
||||
*/
|
||||
CSamplesGeodeticToEcef() {}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -20,7 +21,7 @@ template <class UsingClass> class CBaseStreamStringifier
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend QDebug operator<<(QDebug debug, const UsingClass &uc)
|
||||
friend QDebug &operator<<(QDebug &debug, const UsingClass &uc)
|
||||
{
|
||||
const CBaseStreamStringifier &s = uc;
|
||||
debug << s.stringForStreaming();
|
||||
@@ -33,7 +34,7 @@ template <class UsingClass> class CBaseStreamStringifier
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend QDataStream operator<<(QDataStream stream, const UsingClass &uc)
|
||||
friend QDataStream &operator<<(QDataStream &stream, const UsingClass &uc)
|
||||
{
|
||||
const CBaseStreamStringifier &s = uc;
|
||||
stream << s.stringForStreaming();
|
||||
@@ -46,13 +47,26 @@ template <class UsingClass> class CBaseStreamStringifier
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend CLogMessage operator<<(CLogMessage log, const UsingClass &uc)
|
||||
friend CLogMessage &operator<<(CLogMessage &log, const UsingClass &uc)
|
||||
{
|
||||
const CBaseStreamStringifier &s = uc;
|
||||
log << s.stringForStreaming();
|
||||
return log;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Stream operator << for std::cout
|
||||
* \param ostr
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend std::ostream &operator<<(std::ostream &ostr, const UsingClass &uc)
|
||||
{
|
||||
const CBaseStreamStringifier &s = uc;
|
||||
ostr << s.stringForStreaming().toStdString();
|
||||
return ostr;
|
||||
}
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
* \param y
|
||||
* \param z
|
||||
*/
|
||||
CCoordinateEcef(qreal x, qreal y, qreal z) : CVector3DBase(x, y, z) {}
|
||||
CCoordinateEcef(double x, double y, double z) : CVector3DBase(x, y, z) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by math vector
|
||||
@@ -40,54 +40,54 @@ public:
|
||||
* \brief x
|
||||
* \return
|
||||
*/
|
||||
qreal x() const
|
||||
double x() const
|
||||
{
|
||||
return this->m_vector.x();
|
||||
return this->m_i;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief y
|
||||
* \return
|
||||
*/
|
||||
qreal y() const
|
||||
double y() const
|
||||
{
|
||||
return this->m_vector.y();
|
||||
return this->m_j;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief z
|
||||
* \return
|
||||
*/
|
||||
qreal z() const
|
||||
double z() const
|
||||
{
|
||||
return this->m_vector.z();
|
||||
return this->m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set x
|
||||
* \param x
|
||||
*/
|
||||
void setX(qreal x)
|
||||
void setX(double x)
|
||||
{
|
||||
this->m_vector.setX(x);
|
||||
this->m_i = x;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set y
|
||||
* \param y
|
||||
*/
|
||||
void setY(qreal y)
|
||||
void setY(double y)
|
||||
{
|
||||
this->m_vector.setY(y);
|
||||
this->m_j = y;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set z
|
||||
* \param z
|
||||
*/
|
||||
void setZ(qreal z)
|
||||
void setZ(double z)
|
||||
{
|
||||
this->m_vector.setZ(z);
|
||||
this->m_k = z;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -107,7 +107,10 @@ protected:
|
||||
virtual QString stringForConverter() const
|
||||
{
|
||||
QString s = "ECEF: {x %1, y %2, z %3}";
|
||||
return s.arg(this->x()).arg(this->y()).arg(this->z());
|
||||
s = s.arg(QString::number(this->x(), 'f', 6)).
|
||||
arg(QString::number(this->y(), 'f', 6)).
|
||||
arg(QString::number(this->z(), 'f', 6));
|
||||
return s;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ protected:
|
||||
virtual QString stringForConverter() const
|
||||
{
|
||||
QString s = "Geodetic: {%1, %2, %3}";
|
||||
return s.arg(this->m_latitude.unitValueRoundedWithUnit()).arg(this->m_longitude.unitValueRoundedWithUnit()).arg(this->m_height.unitValueRoundedWithUnit());
|
||||
return s.arg(this->m_latitude.unitValueRoundedWithUnit(6)).arg(this->m_longitude.unitValueRoundedWithUnit(6)).arg(this->m_height.unitValueRoundedWithUnit());
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
* \param longitudeDegrees
|
||||
* \param heightMeters
|
||||
*/
|
||||
CCoordinateGeodetic(qreal latitudeDegrees, qreal longitudeDegrees, qreal heightMeters) :
|
||||
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees, double heightMeters) :
|
||||
m_latitude(latitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_longitude(longitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_height(heightMeters, BlackMisc::PhysicalQuantities::CLengthUnit::m()) {}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -31,7 +31,10 @@ protected:
|
||||
virtual QString stringForConverter() const
|
||||
{
|
||||
QString s = "NED: {N %1, E %2, D %3}";
|
||||
return s.arg(this->north()).arg(this->east()).arg(this->down());
|
||||
s = s.arg(QString::number(this->north(), 'f', 6)).
|
||||
arg(QString::number(this->east(), 'f', 6)).
|
||||
arg(QString::number(this->down(), 'f', 6));
|
||||
return s;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -53,7 +56,7 @@ public:
|
||||
* \param east
|
||||
* \param down
|
||||
*/
|
||||
CCoordinateNed(const CCoordinateGeodetic &referencePosition, qreal north, qreal east, qreal down) : CVector3DBase(north, east, down), m_referencePosition(referencePosition), m_hasReferencePosition(true) {}
|
||||
CCoordinateNed(const CCoordinateGeodetic &referencePosition, double north, double east, double down) : CVector3DBase(north, east, down), m_referencePosition(referencePosition), m_hasReferencePosition(true) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
@@ -135,54 +138,54 @@ public:
|
||||
* \brief North
|
||||
* \return
|
||||
*/
|
||||
qreal north() const
|
||||
double north() const
|
||||
{
|
||||
return this->m_vector.x();
|
||||
return this->m_i;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief East
|
||||
* \return
|
||||
*/
|
||||
qreal east() const
|
||||
double east() const
|
||||
{
|
||||
return this->m_vector.y();
|
||||
return this->m_j;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Down
|
||||
* \return
|
||||
*/
|
||||
qreal down() const
|
||||
double down() const
|
||||
{
|
||||
return this->m_vector.z();
|
||||
return this->m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set north
|
||||
* \param north
|
||||
*/
|
||||
void setNorth(qreal north)
|
||||
void setNorth(double north)
|
||||
{
|
||||
this->m_vector.setX(north);
|
||||
this->m_i = north;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set east
|
||||
* \param east
|
||||
*/
|
||||
void setEast(qreal east)
|
||||
void setEast(double east)
|
||||
{
|
||||
this->m_vector.setY(east);
|
||||
this->m_j = east;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set down
|
||||
* \param down
|
||||
*/
|
||||
void setDown(qreal down)
|
||||
void setDown(double down)
|
||||
{
|
||||
this->m_vector.setZ(down);
|
||||
this->m_k = down;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -68,8 +68,8 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateGeodetic &geo
|
||||
|
||||
CLatitude lat = geo.latitude();
|
||||
CLongitude lon = geo.longitude();
|
||||
qreal latDeg = lat.value(CAngleUnit::deg());
|
||||
qreal lonDeg = lon.value(CAngleUnit::deg());
|
||||
double latDeg = lat.value(CAngleUnit::deg());
|
||||
double lonDeg = lon.value(CAngleUnit::deg());
|
||||
|
||||
double phi = lat.value(CAngleUnit::rad());
|
||||
double lambdaRad = lon.value(CAngleUnit::rad());
|
||||
@@ -90,7 +90,6 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateGeodetic &geo
|
||||
double Y = X * slambda;
|
||||
X *= clambda;
|
||||
double Z = (e2m() * n + h) * sphi;
|
||||
|
||||
CCoordinateEcef result(X, Y, Z);
|
||||
return result;
|
||||
}
|
||||
@@ -246,6 +245,7 @@ CCoordinateGeodetic CCoordinateTransformation::toGeodetic(const CCoordinateEcef
|
||||
CLatitude(latRad, CAngleUnit::rad()),
|
||||
CLongitude(lonRad, CAngleUnit::rad()),
|
||||
CLength(h, CLengthUnit::m()));
|
||||
result.switchUnit(CAngleUnit::deg());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ private:
|
||||
* \brief Equatorial radius of WGS84 ellipsoid (6378137 m)
|
||||
* \return
|
||||
*/
|
||||
static const qreal &EarthRadiusMeters()
|
||||
static const double &EarthRadiusMeters()
|
||||
{
|
||||
static qreal erm = 6378137.0;
|
||||
static double erm = 6378137.0;
|
||||
return erm;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ private:
|
||||
* \brief Flattening of WGS84 ellipsoid (1/298.257223563)
|
||||
* \return
|
||||
*/
|
||||
static const qreal &Flattening()
|
||||
static const double &Flattening()
|
||||
{
|
||||
static qreal f = 1 / 298.257223563;
|
||||
static double f = 1 / 298.257223563;
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ private:
|
||||
* \brief First eccentricity squared
|
||||
* \return
|
||||
*/
|
||||
static const qreal &e2()
|
||||
static const double &e2()
|
||||
{
|
||||
static qreal e2 = (Flattening() * (2 - Flattening()));
|
||||
static double e2 = (Flattening() * (2 - Flattening()));
|
||||
return e2;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ private:
|
||||
* \brief First eccentricity to power of four
|
||||
* \return
|
||||
*/
|
||||
static const qreal &e4()
|
||||
static const double &e4()
|
||||
{
|
||||
static qreal e4 = BlackMisc::Math::CMath::square(e2());
|
||||
static double e4 = BlackMisc::Math::CMath::square(e2());
|
||||
return e4;
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ private:
|
||||
* \brief First eccentricity squared absolute
|
||||
* \return
|
||||
*/
|
||||
static const qreal &e2abs()
|
||||
static const double &e2abs()
|
||||
{
|
||||
static qreal e2abs = abs(e2());
|
||||
static double e2abs = abs(e2());
|
||||
return e2abs;
|
||||
}
|
||||
|
||||
@@ -84,9 +84,9 @@ private:
|
||||
* \brief Eccentricity e2m
|
||||
* \return
|
||||
*/
|
||||
static const qreal &e2m()
|
||||
static const double &e2m()
|
||||
{
|
||||
static qreal e2m = BlackMisc::Math::CMath::square(1 - Flattening());
|
||||
static double e2m = BlackMisc::Math::CMath::square(1 - Flattening());
|
||||
return e2m;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -20,7 +20,7 @@ protected:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CEarthAngle() : CAngle() {}
|
||||
CEarthAngle() : CAngle(0.0, BlackMisc::PhysicalQuantities::CAngleUnit::deg()) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
@@ -35,6 +35,15 @@ protected:
|
||||
*/
|
||||
CEarthAngle(double value, const BlackMisc::PhysicalQuantities::CAngleUnit &unit): CAngle(value, unit) {}
|
||||
|
||||
/*!
|
||||
* \brief String for converter and streaming
|
||||
* \return
|
||||
*/
|
||||
virtual QString stringForConverter() const
|
||||
{
|
||||
return this->unitValueRoundedWithUnit(6);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
* \brief init with value
|
||||
* \param fillValue
|
||||
*/
|
||||
CMatrix1x3(qreal fillValue) : CMatrixBase(fillValue) {}
|
||||
CMatrix1x3(double fillValue) : CMatrixBase(fillValue) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
* \param c2
|
||||
* \param c3
|
||||
*/
|
||||
CMatrix1x3(qreal c1, qreal c2, qreal c3) : CMatrixBase()
|
||||
CMatrix1x3(double c1, double c2, double c3) : CMatrixBase()
|
||||
{
|
||||
this->m_matrix(0, 0) = c1;
|
||||
this->m_matrix(0, 1) = c2;
|
||||
|
||||
@@ -74,8 +74,6 @@ CMatrix3x1 CMatrix3x3::getColumn(int column) const
|
||||
return CMatrix3x1(this->getElement(0, column), this->getElement(1, column), this->getElement(2, column));
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
* \brief init with value
|
||||
* \param fillValue
|
||||
*/
|
||||
CMatrix3x3(qreal fillValue) : CMatrixBase(fillValue) {}
|
||||
CMatrix3x3(double fillValue) : CMatrixBase(fillValue) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
* \brief Calculates the determinant of the matrix
|
||||
* \return
|
||||
*/
|
||||
qreal determinant() const;
|
||||
double determinant() const;
|
||||
|
||||
/*!
|
||||
* \brief Calculate the inverse
|
||||
@@ -88,7 +88,8 @@ public:
|
||||
* \param vector
|
||||
* \return
|
||||
*/
|
||||
CVector3D operator *(const CVector3D &vector) const {
|
||||
CVector3D operator *(const CVector3D &vector) const
|
||||
{
|
||||
CVector3D v(vector);
|
||||
v.matrixMultiplication(*this);
|
||||
return v;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Math
|
||||
/*
|
||||
* Get element by column / row
|
||||
*/
|
||||
template<class ImplMatrix, int Rows, int Columns> qreal CMatrixBase<ImplMatrix, Rows, Columns>::getElement(size_t row, size_t column) const
|
||||
template<class ImplMatrix, int Rows, int Columns> double CMatrixBase<ImplMatrix, Rows, Columns>::getElement(size_t row, size_t column) const
|
||||
{
|
||||
this->checkRange(row, column);
|
||||
return this->m_matrix(row, column);
|
||||
@@ -23,7 +23,7 @@ template<class ImplMatrix, int Rows, int Columns> qreal CMatrixBase<ImplMatrix,
|
||||
/*
|
||||
* Set element by column / row
|
||||
*/
|
||||
template<class ImplMatrix, int Rows, int Columns> void CMatrixBase<ImplMatrix, Rows, Columns>::setElement(size_t row, size_t column, qreal value)
|
||||
template<class ImplMatrix, int Rows, int Columns> void CMatrixBase<ImplMatrix, Rows, Columns>::setElement(size_t row, size_t column, double value)
|
||||
{
|
||||
this->checkRange(row, column);
|
||||
this->m_matrix(row, column) = value;
|
||||
@@ -53,6 +53,21 @@ template<class ImplMatrix, int Rows, int Columns> void CMatrixBase<ImplMatrix, R
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* All values zero?
|
||||
*/
|
||||
template<class ImplMatrix, int Rows, int Columns> bool CMatrixBase<ImplMatrix, Rows, Columns>::isZero() const
|
||||
{
|
||||
for (int r = 0; r < Rows; r++)
|
||||
{
|
||||
for (int c = 0; c < Columns; c++)
|
||||
{
|
||||
if (this->m_matrix(r, c) != 0) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to string
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -23,7 +23,7 @@ template<class ImplMatrix, int Rows, int Columns> class CMatrixBase : public Bla
|
||||
|
||||
protected:
|
||||
// no bug, Qt expects columns rows
|
||||
QGenericMatrix<Columns, Rows, qreal> m_matrix; //!< backing data
|
||||
QGenericMatrix<Columns, Rows, double> m_matrix; //!< backing data
|
||||
|
||||
/*!
|
||||
* \brief Conversion to string
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
* \brief Constructor with init value
|
||||
* \param fillValue
|
||||
*/
|
||||
CMatrixBase(qreal fillValue) : m_matrix() { this->m_matrix.fill(fillValue);}
|
||||
CMatrixBase(double fillValue) : m_matrix() { this->m_matrix.fill(fillValue);}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
* \param factor
|
||||
* \return
|
||||
*/
|
||||
CMatrixBase &operator *=(qreal factor)
|
||||
CMatrixBase &operator *=(double factor)
|
||||
{
|
||||
this->m_matrix *= factor;
|
||||
return (*this);
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
* \param factor
|
||||
* \return
|
||||
*/
|
||||
CMatrixBase &operator *(qreal factor)
|
||||
CMatrixBase &operator *(double factor)
|
||||
{
|
||||
ImplMatrix m(0.0);
|
||||
m += (*this);
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
* \param factor
|
||||
* \return
|
||||
*/
|
||||
CMatrixBase &operator /=(qreal factor)
|
||||
CMatrixBase &operator /=(double factor)
|
||||
{
|
||||
this->m_matrix /= factor;
|
||||
return (*this);
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
* \param factor
|
||||
* \return
|
||||
*/
|
||||
CMatrixBase &operator /(qreal factor)
|
||||
CMatrixBase &operator /(double factor)
|
||||
{
|
||||
ImplMatrix m(0.0);
|
||||
m += (*this);
|
||||
@@ -219,11 +219,17 @@ public:
|
||||
*/
|
||||
void setZero() { this->m_matrix.fill(0.0); }
|
||||
|
||||
/*!
|
||||
* \brief isZero
|
||||
* \return
|
||||
*/
|
||||
bool isZero() const;
|
||||
|
||||
/*!
|
||||
* \brief Set a dedicated value
|
||||
* \param value
|
||||
*/
|
||||
void fill(qreal value) { this->m_matrix.fill(value); }
|
||||
void fill(double value) { this->m_matrix.fill(value); }
|
||||
|
||||
/*!
|
||||
* \brief Get element
|
||||
@@ -231,7 +237,7 @@ public:
|
||||
* \param column
|
||||
* \return
|
||||
*/
|
||||
qreal getElement(size_t row, size_t column) const;
|
||||
double getElement(size_t row, size_t column) const;
|
||||
|
||||
/*!
|
||||
* \brief Get element
|
||||
@@ -239,14 +245,14 @@ public:
|
||||
* \param column
|
||||
* \param value
|
||||
*/
|
||||
void setElement(size_t row, size_t column, qreal value);
|
||||
void setElement(size_t row, size_t column, double value);
|
||||
|
||||
/*!
|
||||
* \brief Get element by ()
|
||||
* \param column
|
||||
* \return
|
||||
*/
|
||||
qreal &operator()(size_t row, size_t column)
|
||||
double &operator()(size_t row, size_t column)
|
||||
{
|
||||
this->checkRange(row, column);
|
||||
return this->m_matrix(row, column);
|
||||
@@ -257,7 +263,7 @@ public:
|
||||
* \param column
|
||||
* \return
|
||||
*/
|
||||
qreal operator()(size_t row, size_t column) const
|
||||
double operator()(size_t row, size_t column) const
|
||||
{
|
||||
return this->getElement(row, column);
|
||||
}
|
||||
|
||||
@@ -25,66 +25,72 @@ public:
|
||||
* \param j
|
||||
* \param k
|
||||
*/
|
||||
CVector3D(qreal i, qreal j, qreal k) : CVector3DBase(i, j, k) {}
|
||||
CVector3D(double i, double j, double k) : CVector3DBase(i, j, k) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by value
|
||||
* \param value
|
||||
*/
|
||||
CVector3D(qreal value) : CVector3DBase(value) {}
|
||||
CVector3D(double value) : CVector3DBase(value) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherVector
|
||||
*/
|
||||
CVector3D(const CVector3D &otherVector) : CVector3DBase(otherVector) {}
|
||||
|
||||
/*!
|
||||
* \brief i
|
||||
* \return
|
||||
*/
|
||||
qreal i() const
|
||||
double i() const
|
||||
{
|
||||
return this->m_vector.x();
|
||||
return this->m_i;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief j
|
||||
* \return
|
||||
*/
|
||||
qreal j() const
|
||||
double j() const
|
||||
{
|
||||
return this->m_vector.y();
|
||||
return this->m_j;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief k
|
||||
* \return
|
||||
*/
|
||||
qreal k() const
|
||||
double k() const
|
||||
{
|
||||
return this->m_vector.z();
|
||||
return this->m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set i
|
||||
* \param i
|
||||
*/
|
||||
void setI(qreal i)
|
||||
void setI(double i)
|
||||
{
|
||||
this->m_vector.setX(i);
|
||||
this->m_i = i;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set j
|
||||
* \param j
|
||||
*/
|
||||
void setJ(qreal j)
|
||||
void setJ(double j)
|
||||
{
|
||||
this->m_vector.setY(j);
|
||||
this->m_j = j;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set k
|
||||
* \param k
|
||||
*/
|
||||
void setK(qreal k)
|
||||
void setK(double k)
|
||||
{
|
||||
this->m_vector.setZ(k);
|
||||
this->m_k = k;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace Math
|
||||
template <class ImplClass> QString CVector3DBase<ImplClass>::stringForConverter() const
|
||||
{
|
||||
QString s = ("{%1, %2, %3}");
|
||||
s = s.arg(this->m_vector.x()).arg(this->m_vector.y()).arg(this->m_vector.z());
|
||||
s = s.arg(QString::number(this->m_i, 'f')).
|
||||
arg(QString::number(this->m_j, 'f')).
|
||||
arg(QString::number(this->m_k, 'f'));
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -34,29 +36,29 @@ template <class ImplClass> void CVector3DBase<ImplClass>::setZero()
|
||||
/*
|
||||
* Vector to zero
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::fill(qreal value)
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::fill(double value)
|
||||
{
|
||||
this->m_vector.setX(value);
|
||||
this->m_vector.setY(value);
|
||||
this->m_vector.setZ(value);
|
||||
this->m_i = value;
|
||||
this->m_j = value;
|
||||
this->m_k = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Element
|
||||
*/
|
||||
template <class ImplClass> qreal CVector3DBase<ImplClass>::getElement(size_t row) const
|
||||
template <class ImplClass> double CVector3DBase<ImplClass>::getElement(size_t row) const
|
||||
{
|
||||
qreal d;
|
||||
double d;
|
||||
switch (row)
|
||||
{
|
||||
case 0:
|
||||
d = this->m_vector.x();
|
||||
d = this->m_i;
|
||||
break;
|
||||
case 1:
|
||||
d = this->m_vector.y();
|
||||
d = this->m_j;
|
||||
break;
|
||||
case 2:
|
||||
d = this->m_vector.z();
|
||||
d = this->m_k;
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT_X(true, "getElement", "Detected invalid index in 3D vector");
|
||||
@@ -69,18 +71,18 @@ template <class ImplClass> qreal CVector3DBase<ImplClass>::getElement(size_t row
|
||||
/*
|
||||
* Set given element
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::setElement(size_t row, qreal value)
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::setElement(size_t row, double value)
|
||||
{
|
||||
switch (row)
|
||||
{
|
||||
case 0:
|
||||
this->m_vector.setX(value);
|
||||
this->m_i = value;
|
||||
break;
|
||||
case 1:
|
||||
this->m_vector.setY(value);
|
||||
this->m_j = value;
|
||||
break;
|
||||
case 2:
|
||||
this->m_vector.setZ(value);
|
||||
this->m_k = value;
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT_X(true, "setElement", "Detected invalid index in 3D vector");
|
||||
@@ -89,15 +91,36 @@ template <class ImplClass> void CVector3DBase<ImplClass>::setElement(size_t row,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Corss product
|
||||
*/
|
||||
template <class ImplClass> ImplClass CVector3DBase<ImplClass>::crossProduct(const ImplClass &otherVector) const
|
||||
{
|
||||
ImplClass v(otherVector);
|
||||
v.m_i = this->m_j * otherVector.m_k - this->m_k * otherVector.m_j;
|
||||
v.m_j = this->m_k * otherVector.m_i - this->m_j * otherVector.m_k;
|
||||
v.m_k = this->m_i * otherVector.m_j - this->m_j * otherVector.m_i;
|
||||
return v;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cross product
|
||||
*/
|
||||
template <class ImplClass> double CVector3DBase<ImplClass>::dotProduct(const ImplClass &otherVector) const
|
||||
{
|
||||
return this->m_i * otherVector.m_i + this->m_j * otherVector.m_j + this->m_k * otherVector.m_k;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Multiply with matrix
|
||||
*/
|
||||
template <class ImplClass> void CVector3DBase<ImplClass>::matrixMultiplication(const CMatrix3x3 &matrix)
|
||||
{
|
||||
CMatrix3x1 m = matrix * (this->toMatrix3x1());
|
||||
this->m_vector.setX(m(0,0));
|
||||
this->m_vector.setY(m(1,0));
|
||||
this->m_vector.setZ(m(2,0));
|
||||
this->m_i = m(0, 0);
|
||||
this->m_j = m(1, 0);
|
||||
this->m_k = m(2, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -105,7 +128,7 @@ template <class ImplClass> void CVector3DBase<ImplClass>::matrixMultiplication(c
|
||||
*/
|
||||
template <class ImplClass> CMatrix3x1 CVector3DBase<ImplClass>::toMatrix3x1() const
|
||||
{
|
||||
return CMatrix3x1(this->m_vector.x(), this->m_vector.y(), this->m_vector.z());
|
||||
return CMatrix3x1(this->m_i, this->m_j, this->m_k);
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define BLACKMISC_MATHVECTOR3DBASE_H
|
||||
|
||||
#include "blackmisc/basestreamstringifier.h"
|
||||
#include <QVector3D>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -25,12 +24,15 @@ template <class ImplClass> class CVector3DBase : public CBaseStreamStringifier<I
|
||||
{
|
||||
protected:
|
||||
|
||||
QVector3D m_vector; //!< Vector data
|
||||
// using own value since Qt QVector3D stores internally as float
|
||||
double m_i; //!< Vector data i
|
||||
double m_j; //!< Vector data j
|
||||
double m_k; //!< Vector data k
|
||||
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CVector3DBase() : m_vector() {}
|
||||
CVector3DBase() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by values
|
||||
@@ -38,13 +40,19 @@ protected:
|
||||
* \param j
|
||||
* \param k
|
||||
*/
|
||||
CVector3DBase(qreal i, qreal j, qreal k) : m_vector(i, j, k) {}
|
||||
CVector3DBase(double i, double j, double k) : m_i(i), m_j(j), m_k(k) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by value
|
||||
* \param value
|
||||
*/
|
||||
CVector3DBase(qreal value) : m_vector(value, value, value) {}
|
||||
CVector3DBase(double value) : m_i(value), m_j(value), m_k(value) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param otherVector
|
||||
*/
|
||||
CVector3DBase(const CVector3DBase &otherVector) : m_i(otherVector.m_i), m_j(otherVector.m_j), m_k(otherVector.m_k) {}
|
||||
|
||||
/*!
|
||||
* \brief String for converter
|
||||
@@ -70,28 +78,28 @@ public:
|
||||
/*!
|
||||
* \brief Set zeros
|
||||
*/
|
||||
void fill(qreal value);
|
||||
void fill(double value);
|
||||
|
||||
/*!
|
||||
* \brief Get element
|
||||
* \param row
|
||||
* \return
|
||||
*/
|
||||
qreal getElement(size_t row) const;
|
||||
double getElement(size_t row) const;
|
||||
|
||||
/*!
|
||||
* \brief Set element
|
||||
* \param row
|
||||
* \param value
|
||||
*/
|
||||
void setElement(size_t row, qreal value);
|
||||
void setElement(size_t row, double value);
|
||||
|
||||
/*!
|
||||
* \brief Operator []
|
||||
* \param row
|
||||
* \return
|
||||
*/
|
||||
qreal operator[](size_t row) const { return this->getElement(row); }
|
||||
double operator[](size_t row) const { return this->getElement(row); }
|
||||
|
||||
|
||||
/*!
|
||||
@@ -99,7 +107,7 @@ public:
|
||||
* \param column
|
||||
* \return
|
||||
*/
|
||||
qreal operator()(size_t row) const { return this->getElement(row); }
|
||||
double operator()(size_t row) const { return this->getElement(row); }
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
@@ -109,7 +117,9 @@ public:
|
||||
bool operator ==(const CVector3DBase &otherVector) const
|
||||
{
|
||||
if (this == &otherVector) return true;
|
||||
return this->m_vector == otherVector.m_vector;
|
||||
return this->m_i == otherVector.m_i &&
|
||||
this->m_j == otherVector.m_j &&
|
||||
this->m_k == otherVector.m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -130,8 +140,10 @@ public:
|
||||
*/
|
||||
CVector3DBase &operator =(const CVector3DBase &otherVector)
|
||||
{
|
||||
if (this == &otherVector) return *this; // Same object?
|
||||
this->m_vector = otherVector.m_vector;
|
||||
if (this == &otherVector) return *this; // Same object?
|
||||
this->m_i = otherVector.m_i;
|
||||
this->m_j = otherVector.m_j;
|
||||
this->m_k = otherVector.m_k;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -142,7 +154,9 @@ public:
|
||||
*/
|
||||
CVector3DBase &operator +=(const CVector3DBase &otherVector)
|
||||
{
|
||||
this->m_vector += otherVector.m_vector;
|
||||
this->m_i += otherVector.m_i;
|
||||
this->m_j += otherVector.m_j;
|
||||
this->m_k += otherVector.m_k;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -166,12 +180,14 @@ public:
|
||||
*/
|
||||
CVector3DBase &operator -=(const CVector3DBase &otherVector)
|
||||
{
|
||||
this->m_vector -= otherVector.m_vector;
|
||||
this->m_i -= otherVector.m_i;
|
||||
this->m_j -= otherVector.m_j;
|
||||
this->m_k -= otherVector.m_k;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Operator +
|
||||
* \brief Operator -
|
||||
* \param otherVector
|
||||
* \return
|
||||
*/
|
||||
@@ -190,7 +206,9 @@ public:
|
||||
*/
|
||||
CVector3DBase &operator *=(const CVector3DBase &otherVector)
|
||||
{
|
||||
this->m_vector *= otherVector.m_vector;
|
||||
this->m_i *= otherVector.m_i;
|
||||
this->m_j *= otherVector.m_j;
|
||||
this->m_k *= otherVector.m_k;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -214,7 +232,9 @@ public:
|
||||
*/
|
||||
CVector3DBase &operator /=(const CVector3DBase &otherVector)
|
||||
{
|
||||
this->m_vector *= otherVector.reciprocalValues().m_vector;
|
||||
this->m_i /= otherVector.m_i;
|
||||
this->m_j /= otherVector.m_j;
|
||||
this->m_k /= otherVector.m_k;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -236,22 +256,14 @@ public:
|
||||
* \param otherVector
|
||||
* \return
|
||||
*/
|
||||
qreal dotProduct(const ImplClass &otherVector) const
|
||||
{
|
||||
return QVector3D::dotProduct(this->m_vector, otherVector.m_vector);
|
||||
}
|
||||
double dotProduct(const ImplClass &otherVector) const;
|
||||
|
||||
/*!
|
||||
* \brief Cross product
|
||||
* \param otherVector
|
||||
* \return
|
||||
*/
|
||||
ImplClass crossProduct(const ImplClass &otherVector) const
|
||||
{
|
||||
ImplClass v;
|
||||
v.m_vector = QVector3D::crossProduct(this->m_vector, otherVector.m_vector);
|
||||
return v;
|
||||
}
|
||||
ImplClass crossProduct(const ImplClass &otherVector) const;
|
||||
|
||||
/*!
|
||||
* \brief Matrix * this vector
|
||||
@@ -268,9 +280,9 @@ public:
|
||||
ImplClass reciprocalValues() const
|
||||
{
|
||||
ImplClass v;
|
||||
v.m_vector.setX(1 / this->m_vector.x());
|
||||
v.m_vector.setY(1 / this->m_vector.y());
|
||||
v.m_vector.setZ(1 / this->m_vector.z());
|
||||
v.m_i = (1 / this->m_i);
|
||||
v.m_j = (1 / this->m_j);
|
||||
v.m_k = (1 / this->m_j);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -278,18 +290,18 @@ public:
|
||||
* \brief Length
|
||||
* \return
|
||||
*/
|
||||
qreal length()const
|
||||
double length()const
|
||||
{
|
||||
return this->m_vector.length();
|
||||
return this->m_i * this->m_j + this->m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Length squared
|
||||
* \return
|
||||
*/
|
||||
qreal lengthSquared()const
|
||||
double lengthSquared()const
|
||||
{
|
||||
return this->m_vector.lengthSquared();
|
||||
return this->m_i * this->m_i + this->m_j * this->m_j + this->m_k * this->m_k;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -302,7 +314,7 @@ public:
|
||||
* \brief Magnitude
|
||||
* \return
|
||||
*/
|
||||
qreal magnitude() const
|
||||
double magnitude() const
|
||||
{
|
||||
return sqrt(this->lengthSquared());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
QT += core testlib
|
||||
QT -= gui
|
||||
|
||||
TARGET = test_blackmisc
|
||||
TEMPLATE = app
|
||||
@@ -11,12 +10,14 @@ DEPENDPATH += . ../../src
|
||||
INCLUDEPATH += . ../../src
|
||||
SOURCES += main.cpp testmain.cpp \
|
||||
testphysicalquantitiesbase.cpp \
|
||||
testaviationbase.cpp
|
||||
testaviationbase.cpp \
|
||||
testvectormatrix.cpp
|
||||
|
||||
HEADERS += testmain.h \
|
||||
testphysicalquantitiesbase.h \
|
||||
blackmisctest.h \
|
||||
testaviationbase.h
|
||||
testaviationbase.h \
|
||||
testvectormatrix.h
|
||||
|
||||
win32-msvc* {
|
||||
PRE_TARGETDEPS += ../../lib/blackmisc.lib
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -14,7 +14,8 @@
|
||||
#include "blackmisc/aviotransponder.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace BlackMiscTest {
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Aviation classes basic tests
|
||||
@@ -52,4 +53,4 @@ private slots:
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // BLACKMISCTEST_TESTAVIATIONBASE_H
|
||||
#endif // guard
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -16,9 +16,11 @@ int CTestMain::unitMain(int argc, char *argv[])
|
||||
{
|
||||
CTestPhysicalQuantitiesBase pqBaseTests ;
|
||||
CTestAviationBase avBaseTests;
|
||||
CTestVectorMatrix vmTests;
|
||||
status |= QTest::qExec(&pqBaseTests, argc, argv);
|
||||
status |= QTest::qExec(&avBaseTests, argc, argv);
|
||||
status |= QTest::qExec(&vmTests, argc, argv);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
#include "testphysicalquantitiesbase.h"
|
||||
#include "testaviationbase.h"
|
||||
#include "testvectormatrix.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace BlackMiscTest{
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* Class firing of all unit tests in this namespace.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H
|
||||
#define BLACKMISCTEST_TESTPHYSICALQUANTITIESBASE_H
|
||||
|
||||
|
||||
35
tests/blackmisc/testvectormatrix.cpp
Normal file
35
tests/blackmisc/testvectormatrix.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "testvectormatrix.h"
|
||||
|
||||
using namespace BlackMisc::Math;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*
|
||||
* Basic tests vector
|
||||
*/
|
||||
void CTestVectorMatrix::vectorBasics()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Matrix tests
|
||||
*/
|
||||
void CTestVectorMatrix::matrixBasics()
|
||||
{
|
||||
CMatrix3x3 m1;
|
||||
CMatrix3x3 m2 = m1 - m1;
|
||||
QVERIFY2(m1.isIdentity(), "Default matrix should be identity");
|
||||
QVERIFY2(m2.isZero(), "Matrix should be zero");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "testvectormatrix.h"
|
||||
|
||||
42
tests/blackmisc/testvectormatrix.h
Normal file
42
tests/blackmisc/testvectormatrix.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKMISCTEST_TESTVECTORMATRIX_H
|
||||
#define BLACKMISCTEST_TESTVECTORMATRIX_H
|
||||
|
||||
#include "blackmisc/mathmatrix3x3.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Vector and Matrix classes basic tests
|
||||
*/
|
||||
class CTestVectorMatrix : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Standard test case constructor
|
||||
* \param parent
|
||||
*/
|
||||
explicit CTestVectorMatrix(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
* \brief Basic unit tests for physical units
|
||||
*/
|
||||
void vectorBasics();
|
||||
/*!
|
||||
* \brief Vertical positions
|
||||
*/
|
||||
void matrixBasics();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user