mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
committed by
Mathew Sutcliffe
parent
229d7c6068
commit
978f3c88e5
@@ -10,77 +10,78 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Physical unit angle (radians, degrees)
|
||||
*/
|
||||
class CAngle : public CPhysicalQuantity<CAngleUnit, CAngle>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CAngle() : CPhysicalQuantity(0, CAngleUnit::defaultUnit()) {}
|
||||
|
||||
/*!
|
||||
* \brief Init by double value
|
||||
* \param value
|
||||
* \param unit
|
||||
*/
|
||||
CAngle(double value, const CAngleUnit &unit): CPhysicalQuantity(value, unit) {}
|
||||
|
||||
/*!
|
||||
* \brief Init as sexagesimal degrees, minutes, seconds
|
||||
* The sign of all parameters must be the same, either all positive or all negative.
|
||||
* \param degrees
|
||||
* \param minutes
|
||||
* \param seconds
|
||||
*/
|
||||
CAngle(int degrees, int minutes, double seconds) :
|
||||
CPhysicalQuantity(
|
||||
degrees + minutes / 100.0 + seconds / 10000.0,
|
||||
CAngleUnit::sexagesimalDeg()) {}
|
||||
|
||||
/*!
|
||||
* \brief Init as sexagesimal degrees, minutes
|
||||
* The sign of both parameters must be the same, either both positive or both negative.
|
||||
* \param degrees
|
||||
* \param minutes
|
||||
*/
|
||||
CAngle(int degrees, double minutes) :
|
||||
CPhysicalQuantity(
|
||||
degrees + minutes / 100.0,
|
||||
CAngleUnit::sexagesimalDegMin()) {}
|
||||
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CAngle() {}
|
||||
|
||||
/*!
|
||||
* \brief Value as factor of PI (e.g. 0.5PI)
|
||||
* \return
|
||||
*/
|
||||
double piFactor() const
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
return BlackMisc::Math::CMath::round(this->value(CAngleUnit::rad()) / BlackMisc::Math::CMath::PI() , 6);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief PI as convenience method
|
||||
* \return
|
||||
*/
|
||||
static const double &PI()
|
||||
{
|
||||
return BlackMisc::Math::CMath::PI();
|
||||
}
|
||||
};
|
||||
/*!
|
||||
* \brief Physical unit angle (radians, degrees)
|
||||
*/
|
||||
class CAngle : public CPhysicalQuantity<CAngleUnit, CAngle>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CAngle() : CPhysicalQuantity(0, CAngleUnit::defaultUnit()) {}
|
||||
|
||||
} // namespace
|
||||
/*!
|
||||
* \brief Init by double value
|
||||
* \param value
|
||||
* \param unit
|
||||
*/
|
||||
CAngle(double value, const CAngleUnit &unit): CPhysicalQuantity(value, unit) {}
|
||||
|
||||
/*!
|
||||
* \brief Init as sexagesimal degrees, minutes, seconds
|
||||
* The sign of all parameters must be the same, either all positive or all negative.
|
||||
* \param degrees
|
||||
* \param minutes
|
||||
* \param seconds
|
||||
*/
|
||||
CAngle(int degrees, int minutes, double seconds) :
|
||||
CPhysicalQuantity(
|
||||
degrees + minutes / 100.0 + seconds / 10000.0,
|
||||
CAngleUnit::sexagesimalDeg()) {}
|
||||
|
||||
/*!
|
||||
* \brief Init as sexagesimal degrees, minutes
|
||||
* The sign of both parameters must be the same, either both positive or both negative.
|
||||
* \param degrees
|
||||
* \param minutes
|
||||
*/
|
||||
CAngle(int degrees, double minutes) :
|
||||
CPhysicalQuantity(
|
||||
degrees + minutes / 100.0,
|
||||
CAngleUnit::sexagesimalDegMin()) {}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Virtual destructor
|
||||
*/
|
||||
virtual ~CAngle() {}
|
||||
|
||||
/*!
|
||||
* \brief Value as factor of PI (e.g. 0.5PI)
|
||||
* \return
|
||||
*/
|
||||
double piFactor() const
|
||||
{
|
||||
return BlackMisc::Math::CMath::round(this->value(CAngleUnit::rad()) / BlackMisc::Math::CMath::PI() , 6);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief PI as convenience method
|
||||
* \return
|
||||
*/
|
||||
static const double &PI()
|
||||
{
|
||||
return BlackMisc::Math::CMath::PI();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CAngle)
|
||||
|
||||
#endif // BLACKMISC_PQANGLE_H
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user