...
This commit is contained in:
@@ -98,18 +98,18 @@ public:
|
||||
|
||||
|
||||
// by default angle is in radians
|
||||
MccAngle(const double& val, const MccRadianTag = MccRadianTag{}) : _angleInRads(val) {}
|
||||
constexpr MccAngle(const double& val, const MccRadianTag = MccRadianTag{}) : _angleInRads(val) {}
|
||||
|
||||
// construct angle in degrees, e.g.:
|
||||
// auto ang = MccAngle{180.0, mcc_degrees};
|
||||
MccAngle(const double& val, const MccDegreeTag) : _angleInRads(val * utils::deg2radCoeff) {}
|
||||
constexpr MccAngle(const double& val, const MccDegreeTag) : _angleInRads(val * utils::deg2radCoeff) {}
|
||||
|
||||
|
||||
|
||||
// constuct angle from sexagesimal representation or floating-point number of degrees, e.g.:
|
||||
// auto ang = MccAngle{"-12:34:56.789"}; // from degrees:minutes:seconds
|
||||
// auto ang = MccAngle{"123.574698"}; // from degrees
|
||||
MccAngle(traits::mcc_input_char_range auto const& val)
|
||||
constexpr MccAngle(traits::mcc_input_char_range auto const& val)
|
||||
{
|
||||
auto res = utils::parsAngleString(val);
|
||||
if (res.has_value()) {
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
// construct angle from sexagesimal representation or floating-point number of degrees, e.g.:
|
||||
// auto ang = MccAngle{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds
|
||||
// auto ang = MccAngle{"123.574698"}; // from degrees
|
||||
MccAngle(traits::mcc_input_char_range auto const& val, const MccHMSTag)
|
||||
constexpr MccAngle(traits::mcc_input_char_range auto const& val, const MccHMSTag)
|
||||
{
|
||||
auto res = utils::parsAngleString(val, true);
|
||||
if (res.has_value()) {
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
virtual ~MccAngle() = default;
|
||||
|
||||
template <std::derived_from<MccAngle> T>
|
||||
auto& operator=(this T&& self, const T& other)
|
||||
constexpr auto& operator=(this T&& self, const T& other)
|
||||
{
|
||||
std::forward<decltype(self)>(self)._angleInRads = other._angleInRads;
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
}
|
||||
|
||||
template <std::derived_from<MccAngle> T>
|
||||
auto& operator=(this T&& self, T&& other)
|
||||
constexpr auto& operator=(this T&& self, T&& other)
|
||||
{
|
||||
std::forward<decltype(self)>(self)._angleInRads = std::move(other._angleInRads);
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto& operator=(this auto&& self, const T& val)
|
||||
constexpr auto& operator=(this auto&& self, const T& val)
|
||||
requires std::is_arithmetic_v<T>
|
||||
{
|
||||
std::forward<decltype(self)>(self)._angleInRads = val;
|
||||
@@ -209,19 +209,19 @@ public:
|
||||
// return _angleInRads;
|
||||
// }
|
||||
|
||||
operator double() const
|
||||
constexpr operator double() const
|
||||
{
|
||||
return _angleInRads;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
T degrees() const
|
||||
constexpr T degrees() const
|
||||
{
|
||||
return _angleInRads * 180.0 / std::numbers::pi;
|
||||
}
|
||||
|
||||
double degrees() const
|
||||
constexpr double degrees() const
|
||||
{
|
||||
return degrees<double>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user