Unit tests for acceleration and more for vector

This commit is contained in:
Klaus Basan
2013-04-25 20:21:04 +02:00
parent 2d8720c6ae
commit 5eac9be7d5
16 changed files with 88 additions and 59 deletions

View File

@@ -5,19 +5,16 @@ TEMPLATE = lib
CONFIG += staticlib
INCLUDEPATH += ..
# DEPENDPATH += . .. // BlackMisc should be independent
# PRECOMPILED_HEADER = stdpch.h
# PRECOMPILED_HEADER = stdpch.h
precompile_header:!isEmpty(PRECOMPILED_HEADER) {
DEFINES += USING_PCH
}
DEFINES += LOG_IN_FILE
HEADERS += *.h \
pqacceleration.h
HEADERS += *.h
SOURCES += *.cpp
DESTDIR = ../../lib

View File

@@ -166,10 +166,10 @@ public:
/*!
* \brief Get row
* \param column
* \param row
* \return
*/
CMatrix1x3 getRow(int column) const;
CMatrix1x3 getRow(int row) const;
};

View File

@@ -375,7 +375,7 @@ public:
*/
double length()const
{
return this->m_i * this->m_j + this->m_k;
return this->m_i + this->m_j + this->m_k;
}
/*!

View File

@@ -1,5 +1,10 @@
#ifndef PQUNITSALL_H
#define PQUNITSALL_H
/* 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 BLACKMISC_PQUNITSALL_H
#define BLACKMISC_PQUNITSALL_H
// All units / quantities, required for the instantiations of the template
// especially as CRTP is used.
@@ -14,5 +19,6 @@
#include "blackmisc/pqtemperature.h"
#include "blackmisc/pqangle.h"
#include "blackmisc/pqtime.h"
#include "blackmisc/pqacceleration.h"
#endif // PQUNITSALL_H
#endif // guard

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2013 VATSIM Community
/* 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/. */

View File

@@ -276,13 +276,15 @@ template <class MU, class PQ> bool CPhysicalQuantity<MU, PQ>::operator <=(const
/*
* Switch to another unit
*/
template <class MU, class PQ> CPhysicalQuantity<MU, PQ> &CPhysicalQuantity<MU, PQ>::switchUnit(const MU &newUnit)
template <class MU, class PQ> PQ &CPhysicalQuantity<MU, PQ>::switchUnit(const MU &newUnit)
{
if (this->m_unit == newUnit) return *this;
double cf = this->m_unit.conversionToUnit(this->m_unitValueD, newUnit);
this->m_unit = newUnit;
this->setUnitValue(cf);
return *this;
if (this->m_unit != newUnit)
{
double cf = this->m_unit.conversionToUnit(this->m_unitValueD, newUnit);
this->m_unit = newUnit;
this->setUnitValue(cf);
}
return static_cast<PQ &>(*this);
}
/*
@@ -407,6 +409,7 @@ template class CPhysicalQuantity<CTemperatureUnit, CTemperature>;
template class CPhysicalQuantity<CSpeedUnit, CSpeed>;
template class CPhysicalQuantity<CAngleUnit, CAngle>;
template class CPhysicalQuantity<CTimeUnit, CTime>;
template class CPhysicalQuantity<CAccelerationUnit, CAcceleration>;
} // namespace
} // namespace

View File

@@ -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/. */
@@ -108,11 +108,11 @@ public:
}
/*!
* \brief Switch unit, e.g. feet meter
* \brief Switch unit, e.g. feet to meter
* \param newUnit
* \return
*/
CPhysicalQuantity &switchUnit(const MU &newUnit);
PQ &switchUnit(const MU &newUnit);
/*!
* \brief Value in SI base unit? Meter is an SI base unit, hertz not!

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2013 VATSIM Community
/* 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/. */
@@ -69,7 +69,8 @@ double CAngleUnit::conversionSexagesimalToSi(const CMeasurementUnit &, double va
QString CAngleUnit::toQStringRounded(double value, int digits) const
{
QString s;
if ((*this) == CAngleUnit::sexagesimalDeg()) {
if ((*this) == CAngleUnit::sexagesimalDeg())
{
// special formatting for sexagesimal degrees
double de = floor(value);
double mi = floor((value - de) * 100.0);
@@ -77,7 +78,9 @@ QString CAngleUnit::toQStringRounded(double value, int digits) const
QString ses = QLocale::system().toString(se, 'f', 2);
s = QString::number(de).append(this->getUnitName()).append(QString::number(mi))
.append("'").append(ses).append("\"");
} else {
}
else
{
s = CMeasurementUnit::toQStringRounded(value, digits);
}
return s;

View File

@@ -731,7 +731,7 @@ public:
*/
static const CAccelerationUnit &m_s2()
{
static CAccelerationUnit ms2("meter/second^2", "m/s^2", true, false, 1, CMeasurementPrefix::None(), 1);
static CAccelerationUnit ms2("meter/second²", "m/s²", true, false, 1, CMeasurementPrefix::None(), 1);
return ms2;
}
@@ -741,13 +741,11 @@ public:
*/
static const CAccelerationUnit &ft_s2()
{
static CAccelerationUnit fts2("feet/seconds^s", "ft/s^2", true, false, 3.28084, CMeasurementPrefix::m(), 0);
static CAccelerationUnit fts2("feet/seconds²", "ft/s²", true, false, 3.28084, CMeasurementPrefix::m(), 0);
return fts2;
}
};
} // namespace
} // namespace
#endif // guard