mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
refactor: rotation
angle unit renamed to revolution
This commit is contained in:
@@ -2,7 +2,7 @@ Angle
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
.. doxygenstruct:: units::radian
|
.. doxygenstruct:: units::radian
|
||||||
.. doxygenstruct:: units::rotation
|
.. doxygenstruct:: units::revolution
|
||||||
.. doxygenstruct:: units::degree
|
.. doxygenstruct:: units::degree
|
||||||
.. doxygenstruct:: units::gradian
|
.. doxygenstruct:: units::gradian
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ int main()
|
|||||||
Angle auto angle = energy / torque;
|
Angle auto angle = energy / torque;
|
||||||
|
|
||||||
std::cout << angle << '\n';
|
std::cout << angle << '\n';
|
||||||
std::cout << quantity_cast<rotation>(angle) << '\n';
|
std::cout << quantity_cast<revolution>(angle) << '\n';
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
std::cout << quantity_cast<degree>(angle) << '\n';
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
std::cout << quantity_cast<gradian>(angle) << '\n';
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ int main()
|
|||||||
Angle auto angle = energy / torque;
|
Angle auto angle = energy / torque;
|
||||||
|
|
||||||
std::cout << angle << '\n';
|
std::cout << angle << '\n';
|
||||||
std::cout << quantity_cast<rotation>(angle) << '\n';
|
std::cout << quantity_cast<revolution>(angle) << '\n';
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
std::cout << quantity_cast<degree>(angle) << '\n';
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
std::cout << quantity_cast<gradian>(angle) << '\n';
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ int main()
|
|||||||
Angle auto angle = energy / torque;
|
Angle auto angle = energy / torque;
|
||||||
|
|
||||||
std::cout << angle << '\n';
|
std::cout << angle << '\n';
|
||||||
std::cout << quantity_cast<rotation>(angle) << '\n';
|
std::cout << quantity_cast<revolution>(angle) << '\n';
|
||||||
std::cout << quantity_cast<degree>(angle) << '\n';
|
std::cout << quantity_cast<degree>(angle) << '\n';
|
||||||
std::cout << quantity_cast<gradian>(angle) << '\n';
|
std::cout << quantity_cast<gradian>(angle) << '\n';
|
||||||
}
|
}
|
||||||
|
@@ -33,9 +33,9 @@
|
|||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
struct radian : named_unit<radian, "rad"> {};
|
struct radian : named_unit<radian, "rad"> {};
|
||||||
struct rotation : named_scaled_unit<rotation, "rot", mag<2>() * mag_pi, radian> {};
|
struct revolution : named_scaled_unit<revolution, "rev", mag<2>() * mag_pi, radian> {};
|
||||||
struct degree : named_scaled_unit<degree, basic_symbol_text{"°", "deg"}, mag<ratio{1, 360}>(), rotation> {};
|
struct degree : named_scaled_unit<degree, basic_symbol_text{"°", "deg"}, mag<ratio{1, 360}>(), revolution> {};
|
||||||
struct gradian : named_scaled_unit<gradian, basic_symbol_text{"ᵍ", "grad"}, mag<ratio{1, 400}>(), rotation> {};
|
struct gradian : named_scaled_unit<gradian, basic_symbol_text{"ᵍ", "grad"}, mag<ratio{1, 400}>(), revolution> {};
|
||||||
|
|
||||||
template<Unit U = radian>
|
template<Unit U = radian>
|
||||||
struct dim_angle : base_dimension<"A", U> {};
|
struct dim_angle : base_dimension<"A", U> {};
|
||||||
@@ -62,12 +62,12 @@ constexpr auto operator"" _q_rad(unsigned long long l)
|
|||||||
constexpr auto operator"" _q_rad(long double l) { return angle<radian, long double>(l); }
|
constexpr auto operator"" _q_rad(long double l) { return angle<radian, long double>(l); }
|
||||||
|
|
||||||
// rot
|
// rot
|
||||||
constexpr auto operator"" _q_rot(unsigned long long l)
|
constexpr auto operator"" _q_rev(unsigned long long l)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(std::in_range<std::int64_t>(l));
|
gsl_ExpectsAudit(std::in_range<std::int64_t>(l));
|
||||||
return angle<rotation, std::int64_t>(static_cast<std::int64_t>(l));
|
return angle<revolution, std::int64_t>(static_cast<std::int64_t>(l));
|
||||||
}
|
}
|
||||||
constexpr auto operator"" _q_rot(long double l) { return angle<rotation, long double>(l); }
|
constexpr auto operator"" _q_rev(long double l) { return angle<revolution, long double>(l); }
|
||||||
|
|
||||||
// deg
|
// deg
|
||||||
constexpr auto operator"" _q_deg(unsigned long long l)
|
constexpr auto operator"" _q_deg(unsigned long long l)
|
||||||
@@ -94,7 +94,7 @@ constexpr auto operator"" _q_grad(long double l) { return angle<gradian, long do
|
|||||||
namespace angle_references {
|
namespace angle_references {
|
||||||
|
|
||||||
inline constexpr auto rad = reference<dim_angle<>, radian>{};
|
inline constexpr auto rad = reference<dim_angle<>, radian>{};
|
||||||
inline constexpr auto rot = reference<dim_angle<>, rotation>{};
|
inline constexpr auto rev = reference<dim_angle<>, revolution>{};
|
||||||
inline constexpr auto deg = reference<dim_angle<>, degree>{};
|
inline constexpr auto deg = reference<dim_angle<>, degree>{};
|
||||||
inline constexpr auto grad = reference<dim_angle<>, gradian>{};
|
inline constexpr auto grad = reference<dim_angle<>, gradian>{};
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ namespace units::aliases::inline angle {
|
|||||||
template<Representation Rep = double>
|
template<Representation Rep = double>
|
||||||
using rad = units::angle<units::radian, Rep>;
|
using rad = units::angle<units::radian, Rep>;
|
||||||
template<Representation Rep = double>
|
template<Representation Rep = double>
|
||||||
using rot = units::angle<units::rotation, Rep>;
|
using rev = units::angle<units::revolution, Rep>;
|
||||||
template<Representation Rep = double>
|
template<Representation Rep = double>
|
||||||
using deg = units::angle<units::degree, Rep>;
|
using deg = units::angle<units::degree, Rep>;
|
||||||
template<Representation Rep = double>
|
template<Representation Rep = double>
|
||||||
|
@@ -31,18 +31,18 @@ namespace {
|
|||||||
using namespace units::references;
|
using namespace units::references;
|
||||||
using namespace units::literals;
|
using namespace units::literals;
|
||||||
|
|
||||||
static_assert(360 * deg == 1 * rot);
|
static_assert(360 * deg == 1 * rev);
|
||||||
static_assert(400 * grad == 1 * rot);
|
static_assert(400 * grad == 1 * rev);
|
||||||
static_assert(std::numbers::pi * 2 * rad == 1. * rot);
|
static_assert(std::numbers::pi * 2 * rad == 1. * rev);
|
||||||
|
|
||||||
static_assert(360_q_deg == 1_q_rot);
|
static_assert(360_q_deg == 1_q_rev);
|
||||||
static_assert(400_q_grad == 1_q_rot);
|
static_assert(400_q_grad == 1_q_rev);
|
||||||
static_assert(std::numbers::pi * quantity_cast<double>(2._q_rad) == quantity_cast<double>(1._q_rot));
|
static_assert(std::numbers::pi * quantity_cast<double>(2._q_rad) == quantity_cast<double>(1._q_rev));
|
||||||
|
|
||||||
static_assert(units::aliases::deg<>(360.) == units::aliases::rot<>(1.));
|
static_assert(units::aliases::deg<>(360.) == units::aliases::rev<>(1.));
|
||||||
static_assert(units::aliases::deg<int>(360) == units::aliases::rot<int>(1));
|
static_assert(units::aliases::deg<int>(360) == units::aliases::rev<int>(1));
|
||||||
static_assert(units::aliases::grad<int>(400) == units::aliases::rot<int>(1));
|
static_assert(units::aliases::grad<int>(400) == units::aliases::rev<int>(1));
|
||||||
static_assert(std::numbers::pi * units::aliases::rad<>(2.) == units::aliases::rot<>(1.));
|
static_assert(std::numbers::pi * units::aliases::rad<>(2.) == units::aliases::rev<>(1.));
|
||||||
|
|
||||||
// solid angle
|
// solid angle
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user