mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 05:04:27 +02:00
dim_velocity renamed to dim_speed
This commit is contained in:
@@ -111,7 +111,7 @@ The above dimensions can be defined in the library with the
|
|||||||
|
|
||||||
struct dim_area : derived_dimension<dim_area, square_metre,
|
struct dim_area : derived_dimension<dim_area, square_metre,
|
||||||
exp<dim_length, 2>> {};
|
exp<dim_length, 2>> {};
|
||||||
struct dim_velocity : derived_dimension<dim_velocity, metre_per_second,
|
struct dim_speed : derived_dimension<dim_speed, metre_per_second,
|
||||||
exp<dim_length, 1>, exp<dim_time, -1>> {};
|
exp<dim_length, 1>, exp<dim_time, -1>> {};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ matter. Even if we define the above as:
|
|||||||
|
|
||||||
struct dim_area : derived_dimension<dim_area, square_metre,
|
struct dim_area : derived_dimension<dim_area, square_metre,
|
||||||
exp<dim_length, 1>, exp<dim_length, 1>> {};
|
exp<dim_length, 1>, exp<dim_length, 1>> {};
|
||||||
struct dim_velocity : derived_dimension<dim_velocity, metre_per_second,
|
struct dim_speed : derived_dimension<dim_speed, metre_per_second,
|
||||||
exp<dim_time, -1>, exp<dim_length, 1>> {};
|
exp<dim_time, -1>, exp<dim_length, 1>> {};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ In order to obtain the base/coherent unit of any dimension type a
|
|||||||
`dimension_unit` helper was introduced::
|
`dimension_unit` helper was introduced::
|
||||||
|
|
||||||
static_assert(std::is_same_v<dimension_unit<si::dim_length>, si::metre>);
|
static_assert(std::is_same_v<dimension_unit<si::dim_length>, si::metre>);
|
||||||
static_assert(std::is_same_v<dimension_unit<si::dim_velocity>, si::metre_per_second>);
|
static_assert(std::is_same_v<dimension_unit<si::dim_speed>, si::metre_per_second>);
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Citations:
|
.. rubric:: Citations:
|
||||||
|
@@ -144,7 +144,7 @@ However, the easiest way to define momentum is just to use the
|
|||||||
|
|
||||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||||
exp<si::dim_mass, 1>,
|
exp<si::dim_mass, 1>,
|
||||||
exp<si::dim_velocity, 1>> {}; // kg ⋅ m/s
|
exp<si::dim_speed, 1>> {}; // kg ⋅ m/s
|
||||||
|
|
||||||
In such a case the library will do its magic and will automatically
|
In such a case the library will do its magic and will automatically
|
||||||
unpack a provided derived dimension to its base dimensions in order to
|
unpack a provided derived dimension to its base dimensions in order to
|
||||||
@@ -296,7 +296,7 @@ does not exist at all. With it `si::kilometre_per_hour` can be defined as::
|
|||||||
|
|
||||||
namespace si {
|
namespace si {
|
||||||
|
|
||||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_velocity, kilometre, hour> {};
|
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ will determine its type. The same applies to the resulting unit. For example:
|
|||||||
using namespace units::physical::si;
|
using namespace units::physical::si;
|
||||||
|
|
||||||
constexpr auto result = 144q_km / 2q_h;
|
constexpr auto result = 144q_km / 2q_h;
|
||||||
static_assert(std::is_same_v<decltype(result)::dimension, dim_velocity>);
|
static_assert(std::is_same_v<decltype(result)::dimension, dim_speed>);
|
||||||
static_assert(std::is_same_v<decltype(result)::unit, kilometre_per_hour>);
|
static_assert(std::is_same_v<decltype(result)::unit, kilometre_per_hour>);
|
||||||
|
|
||||||
However, if the resulting dimension is not predefined by the user the library framework
|
However, if the resulting dimension is not predefined by the user the library framework
|
||||||
|
@@ -30,10 +30,10 @@
|
|||||||
namespace units::physical::cgs {
|
namespace units::physical::cgs {
|
||||||
|
|
||||||
struct centimetre_per_second : unit<centimetre_per_second> {};
|
struct centimetre_per_second : unit<centimetre_per_second> {};
|
||||||
struct dim_velocity : physical::dim_velocity<dim_velocity, centimetre_per_second, dim_length, dim_time> {};
|
struct dim_speed : physical::dim_speed<dim_speed, centimetre_per_second, dim_length, dim_time> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using speed = quantity<dim_velocity, U, Rep>;
|
using speed = quantity<dim_speed, U, Rep>;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ template<typename Child, Unit U, DimensionOf<dim_length> L>
|
|||||||
struct dim_volume : derived_dimension<Child, U, exp<L, 3>> {};
|
struct dim_volume : derived_dimension<Child, U, exp<L, 3>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_length> L, DimensionOf<dim_time> T>
|
template<typename Child, Unit U, DimensionOf<dim_length> L, DimensionOf<dim_time> T>
|
||||||
struct dim_velocity : derived_dimension<Child, U, exp<L, 1>, exp<T, -1>> {};
|
struct dim_speed : derived_dimension<Child, U, exp<L, 1>, exp<T, -1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_length> L, DimensionOf<dim_time> T>
|
template<typename Child, Unit U, DimensionOf<dim_length> L, DimensionOf<dim_time> T>
|
||||||
struct dim_acceleration : derived_dimension<Child, U, exp<L, 1>, exp<T, -2>> {};
|
struct dim_acceleration : derived_dimension<Child, U, exp<L, 1>, exp<T, -2>> {};
|
||||||
@@ -78,7 +78,7 @@ struct dim_acceleration : derived_dimension<Child, U, exp<L, 1>, exp<T, -2>> {};
|
|||||||
template<typename Child, Unit U, DimensionOf<dim_mass> M, DimensionOf<dim_acceleration> A>
|
template<typename Child, Unit U, DimensionOf<dim_mass> M, DimensionOf<dim_acceleration> A>
|
||||||
struct dim_force : derived_dimension<Child, U, exp<M, 1>, exp<A, 1>> {};
|
struct dim_force : derived_dimension<Child, U, exp<M, 1>, exp<A, 1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_mass> M, DimensionOf<dim_velocity> V>
|
template<typename Child, Unit U, DimensionOf<dim_mass> M, DimensionOf<dim_speed> V>
|
||||||
struct dim_momentum : derived_dimension<Child, U, exp<M, 1>, exp<V, 1>> {};
|
struct dim_momentum : derived_dimension<Child, U, exp<M, 1>, exp<V, 1>> {};
|
||||||
|
|
||||||
template<typename Child, Unit U, DimensionOf<dim_force> F, DimensionOf<dim_length> L>
|
template<typename Child, Unit U, DimensionOf<dim_force> F, DimensionOf<dim_length> L>
|
||||||
@@ -207,7 +207,7 @@ template<typename T>
|
|||||||
concept Volume = QuantityOf<T, dim_volume>;
|
concept Volume = QuantityOf<T, dim_volume>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Speed = QuantityOf<T, dim_velocity>;
|
concept Speed = QuantityOf<T, dim_speed>;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Acceleration = QuantityOf<T, dim_acceleration>;
|
concept Acceleration = QuantityOf<T, dim_acceleration>;
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace units::physical::international {
|
namespace units::physical::international {
|
||||||
|
|
||||||
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_velocity, international::mile, si::hour> {};
|
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_speed, international::mile, si::hour> {};
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
@@ -40,9 +40,9 @@ struct dim_mass : physical::dim_mass<gigaelectronvolt> {};
|
|||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using mass = quantity<dim_mass, U, Rep>;
|
using mass = quantity<dim_mass, U, Rep>;
|
||||||
|
|
||||||
struct dim_velocity : physical::dim_velocity<dim_velocity, unitless, dim_length, dim_time> {};
|
struct dim_speed : physical::dim_speed<dim_speed, unitless, dim_length, dim_time> {};
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using speed = quantity<dim_velocity, U, Rep>;
|
using speed = quantity<dim_speed, U, Rep>;
|
||||||
|
|
||||||
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, gigaelectronvolt, dim_length, dim_time> {};
|
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, gigaelectronvolt, dim_length, dim_time> {};
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
@@ -52,7 +52,7 @@ struct dim_force : physical::dim_force<dim_force, square_gigaelectronvolt, dim_m
|
|||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using force = quantity<dim_force, U, Rep>;
|
using force = quantity<dim_force, U, Rep>;
|
||||||
|
|
||||||
struct dim_momentum : physical::dim_momentum<dim_momentum, gigaelectronvolt, dim_mass, dim_velocity> {};
|
struct dim_momentum : physical::dim_momentum<dim_momentum, gigaelectronvolt, dim_mass, dim_speed> {};
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using momentum = quantity<dim_momentum, U, Rep>;
|
using momentum = quantity<dim_momentum, U, Rep>;
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
namespace units::physical::si {
|
namespace units::physical::si {
|
||||||
|
|
||||||
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
|
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
|
||||||
struct dim_momentum : physical::dim_momentum<dim_momentum, kilogram_metre_per_second, dim_mass, dim_velocity> {};
|
struct dim_momentum : physical::dim_momentum<dim_momentum, kilogram_metre_per_second, dim_mass, dim_speed> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using momentum = quantity<dim_momentum, U, Rep>;
|
using momentum = quantity<dim_momentum, U, Rep>;
|
||||||
|
@@ -30,12 +30,12 @@
|
|||||||
namespace units::physical::si {
|
namespace units::physical::si {
|
||||||
|
|
||||||
struct metre_per_second : unit<metre_per_second> {};
|
struct metre_per_second : unit<metre_per_second> {};
|
||||||
struct dim_velocity : physical::dim_velocity<dim_velocity, metre_per_second, dim_length, dim_time> {};
|
struct dim_speed : physical::dim_speed<dim_speed, metre_per_second, dim_length, dim_time> {};
|
||||||
|
|
||||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_velocity, kilometre, hour> {};
|
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using speed = quantity<dim_velocity, U, Rep>;
|
using speed = quantity<dim_speed, U, Rep>;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ static_assert(10q_cm / 5q_s == 2q_cm_per_s);
|
|||||||
static_assert(10q_cm / 2q_cm_per_s == 5q_s);
|
static_assert(10q_cm / 2q_cm_per_s == 5q_s);
|
||||||
static_assert(10q_cm == 2q_cm_per_s * 5q_s);
|
static_assert(10q_cm == 2q_cm_per_s * 5q_s);
|
||||||
|
|
||||||
static_assert(detail::unit_text<dim_velocity, centimetre_per_second>() == "cm/s");
|
static_assert(detail::unit_text<dim_speed, centimetre_per_second>() == "cm/s");
|
||||||
|
|
||||||
// area
|
// area
|
||||||
static_assert(std::is_same_v<ratio_divide<centimetre::ratio, dimension_unit<dim_length>::ratio>, ratio<1>>);
|
static_assert(std::is_same_v<ratio_divide<centimetre::ratio, dimension_unit<dim_length>::ratio>, ratio<1>>);
|
||||||
|
@@ -255,7 +255,7 @@ static_assert(2q_km / 2q_km_per_h == 1q_h);
|
|||||||
// static_assert(2000q_m / 2q_km_per_h == 1q_h); // should not compile
|
// static_assert(2000q_m / 2q_km_per_h == 1q_h); // should not compile
|
||||||
static_assert(quantity_cast<kilometre>(2000q_m) / 2q_km_per_h == 1q_h);
|
static_assert(quantity_cast<kilometre>(2000q_m) / 2q_km_per_h == 1q_h);
|
||||||
|
|
||||||
static_assert(detail::unit_text<dim_velocity, metre_per_second>() == "m/s");
|
static_assert(detail::unit_text<dim_speed, metre_per_second>() == "m/s");
|
||||||
static_assert(kilometre_per_hour::symbol == "km/h");
|
static_assert(kilometre_per_hour::symbol == "km/h");
|
||||||
|
|
||||||
// acceleration
|
// acceleration
|
||||||
|
@@ -43,8 +43,8 @@ struct kelvin : named_unit<kelvin, "K", no_prefix> {};
|
|||||||
// struct kilokelvin : prefixed_unit<kilokelvin, si::kilo, kelvin> {}; // should not compile (prefix not allowed for this reference unit)
|
// struct kilokelvin : prefixed_unit<kilokelvin, si::kilo, kelvin> {}; // should not compile (prefix not allowed for this reference unit)
|
||||||
|
|
||||||
struct metre_per_second : unit<metre_per_second> {};
|
struct metre_per_second : unit<metre_per_second> {};
|
||||||
struct dim_velocity : derived_dimension<dim_velocity, metre_per_second, units::exp<dim_length, 1>, units::exp<dim_time, -1>> {};
|
struct dim_speed : derived_dimension<dim_speed, metre_per_second, units::exp<dim_length, 1>, units::exp<dim_time, -1>> {};
|
||||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_velocity, kilometre, hour> {};
|
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||||
|
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<ratio<1>, metre>>, metre>);
|
static_assert(std::is_same_v<downcast<scaled_unit<ratio<1>, metre>>, metre>);
|
||||||
static_assert(std::is_same_v<downcast<scaled_unit<ratio<1, 1, -2>, metre>>, centimetre>);
|
static_assert(std::is_same_v<downcast<scaled_unit<ratio<1, 1, -2>, metre>>, centimetre>);
|
||||||
|
Reference in New Issue
Block a user