rename MccCoordinate to MccAngle
This commit is contained in:
@@ -55,7 +55,7 @@ static constexpr MccHMSTag mcc_hms{};
|
||||
|
||||
// coordinate representation class
|
||||
|
||||
class MccCoordinate
|
||||
class MccAngle
|
||||
{
|
||||
protected:
|
||||
double _angleInRads{0.0};
|
||||
@@ -68,25 +68,25 @@ public:
|
||||
NORM_KIND_90_90, // [-90,90]
|
||||
};
|
||||
|
||||
MccCoordinate() = default;
|
||||
MccAngle() = default;
|
||||
|
||||
// by default angle is in radians
|
||||
MccCoordinate(std::convertible_to<double> auto const& val, const MccRadianTag tag = MccRadianTag{})
|
||||
MccAngle(std::convertible_to<double> auto const& val, const MccRadianTag tag = MccRadianTag{})
|
||||
: _angleInRads(val)
|
||||
{
|
||||
}
|
||||
|
||||
// construct angle in degrees, e.g.:
|
||||
// auto ang = MccCoordinate{180.0, mcc_degrees};
|
||||
MccCoordinate(std::convertible_to<double> auto const& val, const MccDegreeTag tag)
|
||||
// auto ang = MccAngle{180.0, mcc_degrees};
|
||||
MccAngle(std::convertible_to<double> auto const& val, const MccDegreeTag tag)
|
||||
{
|
||||
_angleInRads = val * utils::deg2radCoeff;
|
||||
}
|
||||
|
||||
// constuct angle from sexagesimal representation or floating-point number of degrees, e.g.:
|
||||
// auto ang = MccCoordinate{"-12:34:56.789"}; // from degrees:minutes:seconds
|
||||
// auto ang = MccCoordinate{"123.574698"}; // from degrees
|
||||
MccCoordinate(traits::mcc_input_char_range auto const& val)
|
||||
// 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)
|
||||
{
|
||||
auto res = utils::parsAngleString(val);
|
||||
if (res.has_value()) {
|
||||
@@ -97,9 +97,9 @@ public:
|
||||
}
|
||||
|
||||
// construct angle from sexagesimal representation or floating-point number of degrees, e.g.:
|
||||
// auto ang = MccCoordinate{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds
|
||||
// auto ang = MccCoordinate{"123.574698"}; // from degrees
|
||||
MccCoordinate(traits::mcc_input_char_range auto const& val, const MccHMSTag)
|
||||
// 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)
|
||||
{
|
||||
auto res = utils::parsAngleString(val, true);
|
||||
if (res.has_value()) {
|
||||
@@ -109,11 +109,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~MccCoordinate() = default;
|
||||
virtual ~MccAngle() = default;
|
||||
|
||||
// normalize coordinate
|
||||
template <norm_kind_t KIND>
|
||||
MccCoordinate& normalize()
|
||||
MccAngle& normalize()
|
||||
{
|
||||
_angleInRads = std::fmod(_angleInRads, std::numbers::pi * 2.0);
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
MccCoordinate& normalize()
|
||||
MccAngle& normalize()
|
||||
{
|
||||
return normalize<NORM_KIND_0_360>();
|
||||
}
|
||||
@@ -175,68 +175,68 @@ public:
|
||||
return sexagesimal<std::string>(hms, prec);
|
||||
}
|
||||
|
||||
friend MccCoordinate operator+(std::convertible_to<MccCoordinate> auto&& left,
|
||||
std::convertible_to<MccCoordinate> auto&& right)
|
||||
friend MccAngle operator+(std::convertible_to<MccAngle> auto&& left,
|
||||
std::convertible_to<MccAngle> auto&& right)
|
||||
{
|
||||
// return std::forward<decltype(left)>(left)._angleInRads +
|
||||
// std::forward<decltype(right)>(right)._angleInRads;
|
||||
return MccCoordinate{std::forward<decltype(left)>(left)}._angleInRads +
|
||||
MccCoordinate{std::forward<decltype(right)>(right)}._angleInRads;
|
||||
return MccAngle{std::forward<decltype(left)>(left)}._angleInRads +
|
||||
MccAngle{std::forward<decltype(right)>(right)}._angleInRads;
|
||||
}
|
||||
// friend MccCoordinate operator+(const MccCoordinate& left, const MccCoordinate& right)
|
||||
// friend MccAngle operator+(const MccAngle& left, const MccAngle& right)
|
||||
// {
|
||||
// return left._angleInRads + right._angleInRads;
|
||||
// }
|
||||
|
||||
|
||||
friend MccCoordinate operator-(std::convertible_to<MccCoordinate> auto&& left,
|
||||
std::convertible_to<MccCoordinate> auto&& right)
|
||||
friend MccAngle operator-(std::convertible_to<MccAngle> auto&& left,
|
||||
std::convertible_to<MccAngle> auto&& right)
|
||||
{
|
||||
// return std::forward<decltype(left)>(left)._angleInRads -
|
||||
// std::forward<decltype(right)>(right)._angleInRads;
|
||||
return MccCoordinate{std::forward<decltype(left)>(left)}._angleInRads -
|
||||
MccCoordinate{std::forward<decltype(right)>(right)}._angleInRads;
|
||||
return MccAngle{std::forward<decltype(left)>(left)}._angleInRads -
|
||||
MccAngle{std::forward<decltype(right)>(right)}._angleInRads;
|
||||
}
|
||||
// friend MccCoordinate operator-(const MccCoordinate& left, const MccCoordinate& right)
|
||||
// friend MccAngle operator-(const MccAngle& left, const MccAngle& right)
|
||||
// {
|
||||
// return left._angleInRads + right._angleInRads;
|
||||
// }
|
||||
|
||||
template <typename T>
|
||||
MccCoordinate operator*(T&& scalar)
|
||||
MccAngle operator*(T&& scalar)
|
||||
requires std::is_arithmetic_v<std::remove_cvref_t<T>>
|
||||
{
|
||||
return _angleInRads * scalar;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MccCoordinate operator/(T&& scalar)
|
||||
MccAngle operator/(T&& scalar)
|
||||
requires std::is_arithmetic_v<std::remove_cvref_t<T>>
|
||||
{
|
||||
return _angleInRads / scalar;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MccCoordinate operator-() // unary '-'
|
||||
MccAngle operator-() // unary '-'
|
||||
requires std::is_arithmetic_v<std::remove_cvref_t<T>>
|
||||
{
|
||||
return -_angleInRads;
|
||||
}
|
||||
|
||||
MccCoordinate& operator+=(const MccCoordinate& v)
|
||||
MccAngle& operator+=(const MccAngle& v)
|
||||
{
|
||||
_angleInRads += v._angleInRads;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MccCoordinate& operator-=(const MccCoordinate& v)
|
||||
MccAngle& operator-=(const MccAngle& v)
|
||||
{
|
||||
_angleInRads += v._angleInRads;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MccCoordinate& operator*=(T&& scalar)
|
||||
MccAngle& operator*=(T&& scalar)
|
||||
requires std::is_arithmetic_v<std::remove_cvref_t<T>>
|
||||
{
|
||||
_angleInRads *= scalar;
|
||||
@@ -244,19 +244,19 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MccCoordinate& operator/=(T&& scalar)
|
||||
MccAngle& operator/=(T&& scalar)
|
||||
requires std::is_arithmetic_v<std::remove_cvref_t<T>>
|
||||
{
|
||||
_angleInRads /= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto operator<=>(const MccCoordinate& other) const
|
||||
auto operator<=>(const MccAngle& other) const
|
||||
{
|
||||
return _angleInRads <=> other._angleInRads;
|
||||
}
|
||||
|
||||
auto operator==(const MccCoordinate& other) const
|
||||
auto operator==(const MccAngle& other) const
|
||||
{
|
||||
return _angleInRads == other._angleInRads;
|
||||
}
|
||||
@@ -279,7 +279,7 @@ enum class MccNormCoordKind {
|
||||
};
|
||||
|
||||
template <MccNormCoordKind KIND = MccNormCoordKind::NORM_KIND_0_360>
|
||||
class MccNormCoordinate : public MccCoordinate
|
||||
class MccNormCoordinate : public MccAngle
|
||||
{
|
||||
public:
|
||||
static constexpr MccNormCoordKind normKind = KIND;
|
||||
|
||||
Reference in New Issue
Block a user