mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
First major wave of PQ refactoring, including but not limited to:
* Default unit is more clearly stated in one place, not restated in many different places, and is not always the SI unit * Converter strategy pattern in CMeasurementUnit, covering linear, affine, and different kinds of sexagesimal units * General reorganization of CMeasurementUnit construction and CPhysicalQuantity methods, not removing any behvaiour * Move duplicated method unitFromSymbol from derived classes into base class CMeasurementUnit * For DBus, CPhysicalQuantity marshals both in its own unit and in the default unit
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#ifndef BLACKMISC_MATHEMATICS_H
|
||||
#define BLACKMISC_MATHEMATICS_H
|
||||
#include <QtCore/qmath.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -70,6 +71,26 @@ public:
|
||||
*/
|
||||
static double roundEpsilon(double value, double epsilon);
|
||||
|
||||
/*!
|
||||
* \brief Nearest integer not greater in magnitude than value, correcting for epsilon
|
||||
* \param value
|
||||
* \param epsilon
|
||||
*/
|
||||
static inline double trunc(double value, double epsilon = 1e-10)
|
||||
{
|
||||
return value < 0 ? ceil(value - epsilon) : floor(value + epsilon);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Fractional part of value
|
||||
* \param value
|
||||
*/
|
||||
static inline double fract(double value)
|
||||
{
|
||||
double unused;
|
||||
return modf(value, &unused);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief PI
|
||||
* \return
|
||||
|
||||
Reference in New Issue
Block a user