diff --git a/README.md b/README.md index 67d8bd14..8a694706 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,13 @@ and dimensional analysis can be performed without sacrificing on accuracy. Pleas the below example for a quick preview of basic library features: ```cpp -#include -#include +#include +#include #include using namespace units::physical; -constexpr Velocity auto avg_speed(Length auto d, Time auto t) +constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } @@ -64,10 +64,10 @@ constexpr Velocity auto avg_speed(Length auto d, Time auto t) int main() { using namespace units::physical::si::literals; - Velocity auto v1 = avg_speed(220q_km, 2q_h); - Velocity auto v2 = avg_speed(si::length(140), si::time(2)); - Velocity auto v3 = quantity_cast(v2); - Velocity auto v4 = quantity_cast(v3); + Speed auto v1 = avg_speed(220q_km, 2q_h); + Speed auto v2 = avg_speed(si::length(140), si::time(2)); + Speed auto v3 = quantity_cast(v2); + Speed auto v4 = quantity_cast(v3); std::cout << v1 << '\n'; // 110 km/h std::cout << v2 << '\n'; // 70 mi/h diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 78260b91..37b1322b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -25,6 +25,8 @@ - Added a lot of prefixes to named units and introduced `alias_unit` (thanks [@yasamoka](https://github.com/yasamoka)) - Linking with Conan targets only when they exists ([#98](https://github.com/mpusz/units/issues/98)) - All physical dimensions and units put into `physical` namespace + - CMake improvements + - Velocity renamed to speed - ... Many thanks to GitHub users [@oschonrock](https://github.com/oschonrock) and diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 0e7f2a81..9009f346 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -164,7 +164,7 @@ struct kilometre : prefixed_unit {}; struct second : named_unit {}; struct hour : named_scaled_unit, second> {}; -// velocity +// speed struct metre_per_second : unit {}; struct kilometre_per_hour : deduced_unit {}; @@ -176,7 +176,7 @@ namespace units::physical::us { struct yard : named_scaled_unit, si::metre> {}; struct mile : named_scaled_unit, yard> {}; -// velocity +// speed struct mile_per_hour : deduced_unit {}; } @@ -285,7 +285,7 @@ struct derived_dimension_base; } ``` -A derived dimension can be formed from multiple exponents (i.e. velocity is represented as +A derived dimension can be formed from multiple exponents (i.e. speed is represented as `exp, exp`). It is also possible to form a derived dimension with only one exponent (i.e. frequency is represented as just `exp`). @@ -734,11 +734,11 @@ temporary results of calculations: ```cpp units::Length auto d1 = 123q_m; units::Time auto t1 = 10q_s; -units::Velocity auto v1 = avg_speed(d1, t1); +units::Speed auto v1 = avg_speed(d1, t1); auto temp1 = v1 * 50q_m; // intermediate unknown dimension -units::Velocity auto v2 = temp1 / 100q_m; // back to known dimensions again +units::Speed auto v2 = temp1 / 100q_m; // back to known dimensions again units::Length auto d2 = v2 * 60q_s; ``` diff --git a/docs/framework/constants.rst b/docs/framework/constants.rst index 3fef5773..95336190 100644 --- a/docs/framework/constants.rst +++ b/docs/framework/constants.rst @@ -19,7 +19,7 @@ For example the speed of light constant in :term:`SI` is defined as:: namespace si::si2019 { template - inline constexpr auto speed_of_light = velocity(299792458); + inline constexpr auto speed_of_light = speed(299792458); } @@ -28,6 +28,6 @@ The same constant defined for natural units may be provided as:: namespace natural { template - inline constexpr auto speed_of_light = velocity(1); + inline constexpr auto speed_of_light = speed(1); } diff --git a/docs/framework/dimensions.rst b/docs/framework/dimensions.rst index 41a366f5..ce6a91b4 100644 --- a/docs/framework/dimensions.rst +++ b/docs/framework/dimensions.rst @@ -5,7 +5,7 @@ Dimensions In the previous chapter we briefly introduced the notion of a physical :term:`dimension`. Now it is time to learn much more about this subject. -Length, time, velocity, area, energy are only a few examples of physical +Length, time, speed, area, energy are only a few examples of physical dimensions. Operations @@ -45,7 +45,7 @@ probably will always end up in a quantity of a yet another dimension: Length auto dist2 = 3q_m; Time auto dur1 = 2q_s; Area auto res1 = dist1 * dist2; // 6 m² - Velocity auto res2 = dist1 / dur1; // 1 m/s + Speed auto res2 = dist1 / dur1; // 1 m/s Frequency auto res3 = 10 / dur1; // 5 Hz However, please note that there is an exception from the above rule. @@ -96,12 +96,12 @@ The quantities of derived dimensions are called quantities. This means that they are created by multiplying or dividing quantities of other dimensions. -Looking at the previous code snippets the area, velocity, or frequency are +Looking at the previous code snippets the area, speed, or frequency are the examples of such quantities. Each derived quantity can be represented as a unique list of exponents of base quantities. For example: - an area is a length base quantity raised to the exponent ``2`` -- a velocity is formed from the length base quantity with exponent ``1`` +- a speed is formed from the length base quantity with exponent ``1`` and time base quantity with exponent ``-1``. The above dimensions can be defined in the library with the diff --git a/docs/framework/quantities.rst b/docs/framework/quantities.rst index 00f8c8ea..a5191f03 100644 --- a/docs/framework/quantities.rst +++ b/docs/framework/quantities.rst @@ -82,14 +82,14 @@ quantities. The usage of such a function can look as follows:: using namespace units::physical::si::literals; using namespace units::physical::international::literals; - constexpr Velocity auto v1 = avg_speed(220q_km, 2q_h); - constexpr Velocity auto v2 = avg_speed(140q_mi, 2q_h); + constexpr Speed auto v1 = avg_speed(220q_km, 2q_h); + constexpr Speed auto v2 = avg_speed(140q_mi, 2q_h); In this and all other physical units libraries such a function can be implemented as:: - constexpr si::velocity avg_speed(si::length d, - si::time t) + constexpr si::speed avg_speed(si::length d, + si::time t) { return d / t; } @@ -114,7 +114,7 @@ are returning a physical quantity of a correct dimension. For this dimension-specific concepts come handy again and with usage of C++20 generic functions our function can look as simple as:: - constexpr Velocity auto avg_speed(Length auto d, Time auto t) + constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } @@ -141,7 +141,7 @@ but often we would like to know a specific type too. We have two options here: - query the actual dimension, unit, and representation types:: - constexpr Velocity auto v = avg_speed(220q_km, 2q_h); + constexpr Speed auto v = avg_speed(220q_km, 2q_h); using quantity_type = decltype(v); using dimension_type = quantity_type::dimension; using unit_type = quantity_type::unit; @@ -149,9 +149,9 @@ but often we would like to know a specific type too. We have two options here: - convert or cast to a desired quantity type:: - constexpr Velocity auto v1 = avg_speed(220.q_km, 2q_h); - constexpr si::velocity v2 = v1; - constexpr Velocity auto v3 = quantity_cast(v1); + constexpr Speed auto v1 = avg_speed(220.q_km, 2q_h); + constexpr si::speed v2 = v1; + constexpr Speed auto v3 = quantity_cast(v1); .. seealso:: diff --git a/docs/framework/text_output.rst b/docs/framework/text_output.rst index 2a10e41a..a127b9dd 100644 --- a/docs/framework/text_output.rst +++ b/docs/framework/text_output.rst @@ -14,8 +14,8 @@ stream:: using namespace units::physical::si::literals; using namespace units::physical::international::literals; - constexpr Velocity auto v1 = avg_speed(220.q_km, 2q_h); - constexpr Velocity auto v2 = avg_speed(140.q_mi, 2q_h); + constexpr Speed auto v1 = avg_speed(220.q_km, 2q_h); + constexpr Speed auto v2 = avg_speed(140.q_mi, 2q_h); std::cout << v1 << '\n'; // 110 km/h std::cout << v2 << '\n'; // 70 mi/h diff --git a/docs/framework/units.rst b/docs/framework/units.rst index 47d4a319..1b505429 100644 --- a/docs/framework/units.rst +++ b/docs/framework/units.rst @@ -137,7 +137,7 @@ where ``kilogram_metre_per_second`` is defined as:: struct kilogram_metre_per_second : unit {}; However, the easiest way to define momentum is just to use the -`si::velocity` derived dimension in the recipe: +`si::speed` derived dimension in the recipe: .. code-block:: :emphasize-lines: 3 diff --git a/docs/glossary.rst b/docs/glossary.rst index a880f4ee..34c05457 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -136,7 +136,7 @@ ISO 80000 [1]_ definitions - A power of a `base unit` is the `base unit` raised to an exponent. - Coherence can be determined only with respect to a particular `system of quantities` and a given set of `base units `. That is, if the metre and the second are - base units, the metre per second is the coherent derived unit of velocity. + base units, the metre per second is the coherent derived unit of speed. system of units - Set of `base units ` and `derived units `, together with diff --git a/docs/quick_start.rst b/docs/quick_start.rst index d6d2ac14..f6dc9f60 100644 --- a/docs/quick_start.rst +++ b/docs/quick_start.rst @@ -28,13 +28,13 @@ but still easy to use interface where all unit conversions and dimensional analy performed without sacrificing on accuracy. Please see the below example for a quick preview of basic library features:: - #include - #include + #include + #include #include using namespace units::physical; - constexpr Velocity auto avg_speed(Length auto d, Time auto t) + constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } @@ -42,10 +42,10 @@ of basic library features:: int main() { using namespace units::physical::si::literals; - Velocity auto v1 = avg_speed(220q_km, 2q_h); - Velocity auto v2 = avg_speed(si::length(140), si::time(2)); - Velocity auto v3 = quantity_cast(v2); - Velocity auto v4 = quantity_cast(v3); + Speed auto v1 = avg_speed(220q_km, 2q_h); + Speed auto v2 = avg_speed(si::length(140), si::time(2)); + Speed auto v3 = quantity_cast(v2); + Speed auto v4 = quantity_cast(v3); std::cout << v1 << '\n'; // 110 km/h std::cout << v2 << '\n'; // 70 mi/h diff --git a/docs/use_cases/legacy_interfaces.rst b/docs/use_cases/legacy_interfaces.rst index e689a373..2f01632c 100644 --- a/docs/use_cases/legacy_interfaces.rst +++ b/docs/use_cases/legacy_interfaces.rst @@ -19,18 +19,18 @@ pass it to the library's output: .. code-block:: #include "legacy.h" - #include + #include using namespace units::physical; - constexpr Velocity auto avg_speed(Length auto d, Time auto t) + constexpr Speed auto avg_speed(Length auto d, Time auto t) { return d / t; } void print_eta(Length auto d, Time auto t) { - Velocity auto v = avg_speed(d, t); + Speed auto v = avg_speed(d, t); legacy::print_eta(quantity_cast(v).count()); } diff --git a/example/avg_speed.cpp b/example/avg_speed.cpp index 7113dfc4..dcad8f5c 100644 --- a/example/avg_speed.cpp +++ b/example/avg_speed.cpp @@ -20,23 +20,23 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#include -#include +#include +#include +#include #include namespace { using namespace units::physical; -constexpr si::velocity +constexpr si::speed fixed_int_si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr si::velocity +constexpr si::speed fixed_double_si_avg_speed(si::length d, si::time t) { @@ -44,21 +44,21 @@ fixed_double_si_avg_speed(si::length d, } template -constexpr Velocity AUTO si_avg_speed(si::length d, +constexpr Speed AUTO si_avg_speed(si::length d, si::time t) { return d / t; } -constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) +constexpr Speed AUTO avg_speed(Length AUTO d, Time AUTO t) { return d / t; } -template -void print_result(D distance, T duration, V velocity) +template +void print_result(D distance, T duration, V speed) { - const auto result_in_kmph = units::quantity_cast>(velocity); + const auto result_in_kmph = units::quantity_cast>(speed); std::cout << "Average speed of a car that makes " << distance << " in " << duration << " is " << result_in_kmph << ".\n"; } diff --git a/example/hello_units.cpp b/example/hello_units.cpp index 51ba2ff3..25d20810 100644 --- a/example/hello_units.cpp +++ b/example/hello_units.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#include +#include +#include #include #include using namespace units::physical; -constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) +constexpr Speed AUTO avg_speed(Length AUTO d, Time AUTO t) { return d / t; } @@ -35,10 +35,10 @@ constexpr Velocity AUTO avg_speed(Length AUTO d, Time AUTO t) int main() { using namespace units::physical::si::literals; - Velocity AUTO v1 = avg_speed(220q_km, 2q_h); - Velocity AUTO v2 = avg_speed(si::length(140), si::time(2)); - Velocity AUTO v3 = quantity_cast(v2); - Velocity AUTO v4 = quantity_cast(v3); + Speed AUTO v1 = avg_speed(220q_km, 2q_h); + Speed AUTO v2 = avg_speed(si::length(140), si::time(2)); + Speed AUTO v3 = quantity_cast(v2); + Speed AUTO v4 = quantity_cast(v3); std::cout << v1 << '\n'; // 110 km/h std::cout << fmt::format("{}", v2) << '\n'; // 70 mi/h diff --git a/example/kalman_filter-alpha_beta_filter_example2.cpp b/example/kalman_filter-alpha_beta_filter_example2.cpp index f2c6b893..72369ea8 100644 --- a/example/kalman_filter-alpha_beta_filter_example2.cpp +++ b/example/kalman_filter-alpha_beta_filter_example2.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -12,25 +12,24 @@ namespace { -using namespace units; - -template +template struct state_variable { Q estimated_current_state; Q predicted_next_state; }; -using namespace units::physical::si; +using namespace units::physical; +using namespace units::physical::si::literals; constexpr auto radar_transmit_interval = 5.0q_s; constexpr double kalman_range_gain = 0.2; constexpr double kalman_speed_gain = 0.1; struct state { - state_variable> range; - state_variable> speed; + state_variable> range; + state_variable> speed; - constexpr void estimate(const state& previous_state, const length& measurement) + constexpr void estimate(const state& previous_state, const si::length& measurement) { auto const innovation = measurement - previous_state.range.predicted_next_state; range.estimated_current_state = previous_state.range.predicted_next_state + kalman_range_gain * innovation; diff --git a/example/linear_algebra.cpp b/example/linear_algebra.cpp index 079f6e7c..b93794c6 100644 --- a/example/linear_algebra.cpp +++ b/example/linear_algebra.cpp @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include #include #include diff --git a/example/measurement.cpp b/example/measurement.cpp index 07db5f86..372a5e57 100644 --- a/example/measurement.cpp +++ b/example/measurement.cpp @@ -162,7 +162,7 @@ void example() const auto a = si::acceleration>(measurement(9.8, 0.1)); const auto t = si::time>(measurement(1.2, 0.1)); - const Velocity AUTO v1 = a * t; + const Speed AUTO v1 = a * t; std::cout << a << " * " << t << " = " << v1 << " = " << quantity_cast(v1) << '\n'; si::length> length(measurement(123., 1.)); diff --git a/example/total_energy.cpp b/example/total_energy.cpp index eab1dd0b..4b15ca92 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,7 +32,7 @@ namespace { using namespace units::physical; -Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Velocity AUTO c) +Energy AUTO total_energy(Momentum AUTO p, Mass AUTO m, Speed AUTO c) { return sqrt(pow<2>(p * c) + pow<2>(m * pow<2>(c))); } @@ -42,7 +42,7 @@ void si_example() using namespace units::physical::si; using GeV = gigaelectronvolt; - constexpr Velocity AUTO c = si2019::speed_of_light<>; + constexpr Speed AUTO c = si2019::speed_of_light<>; std::cout << "\n*** SI units (c = " << c << ") ***\n"; @@ -73,7 +73,7 @@ void natural_example() using namespace units::physical::natural; using GeV = gigaelectronvolt; - constexpr Velocity AUTO c = speed_of_light<>; + constexpr Speed AUTO c = speed_of_light<>; const momentum p(4); const mass m(3); const Energy AUTO E = total_energy(p, m, c); diff --git a/example/unknown_dimension.cpp b/example/unknown_dimension.cpp index 6b213871..f6437b0c 100644 --- a/example/unknown_dimension.cpp +++ b/example/unknown_dimension.cpp @@ -20,13 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include namespace { template -constexpr units::physical::Velocity AUTO avg_speed(D d, T t) +constexpr units::physical::Speed AUTO avg_speed(D d, T t) { return d / t; } @@ -38,10 +38,10 @@ void example() Length AUTO d1 = 123q_m; Time AUTO t1 = 10q_s; - Velocity AUTO v1 = avg_speed(d1, t1); + Speed AUTO v1 = avg_speed(d1, t1); auto temp1 = v1 * 50q_m; // produces intermediate unknown dimension with 'unknown_coherent_unit' as its 'coherent_unit' - Velocity AUTO v2 = temp1 / 100q_m; // back to known dimensions again + Speed AUTO v2 = temp1 / 100q_m; // back to known dimensions again Length AUTO d2 = v2 * 60q_s; std::cout << "d1 = " << d1 << '\n'; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 958f0527..4d5cb911 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,7 @@ add_library(units INTERFACE) # include/units/si/frequency.h # include/units/si/length.h # include/units/si/time.h -# include/units/si/velocity.h +# include/units/si/speed.h #) target_compile_features(units INTERFACE cxx_std_20) target_link_libraries(units diff --git a/src/include/units/bits/derived_dimension_base.h b/src/include/units/bits/derived_dimension_base.h index c58ec217..71fdcc1b 100644 --- a/src/include/units/bits/derived_dimension_base.h +++ b/src/include/units/bits/derived_dimension_base.h @@ -35,7 +35,7 @@ namespace units::detail { * quantities as a product of powers of factors corresponding to the base quantities, omitting any numerical factors. * A power of a factor is the factor raised to an exponent. * - * A derived dimension can be formed from multiple exponents (i.e. velocity is represented as "exp, exp"). + * A derived dimension can be formed from multiple exponents (i.e. speed is represented as "exp, exp"). * It is also possible to form a derived dimension with only one exponent (i.e. frequency is represented as just * "exp"). * diff --git a/src/include/units/physical/cgs/acceleration.h b/src/include/units/physical/cgs/acceleration.h index 232310c1..c3609212 100644 --- a/src/include/units/physical/cgs/acceleration.h +++ b/src/include/units/physical/cgs/acceleration.h @@ -23,7 +23,7 @@ #pragma once #include -#include +#include #include namespace units::physical::cgs { diff --git a/src/include/units/physical/cgs/velocity.h b/src/include/units/physical/cgs/speed.h similarity index 88% rename from src/include/units/physical/cgs/velocity.h rename to src/include/units/physical/cgs/speed.h index 33387715..0a988c49 100644 --- a/src/include/units/physical/cgs/velocity.h +++ b/src/include/units/physical/cgs/speed.h @@ -33,13 +33,13 @@ struct centimetre_per_second : unit {}; struct dim_velocity : physical::dim_velocity {}; template -using velocity = quantity; +using speed = quantity; inline namespace literals { // cmps -constexpr auto operator"" q_cm_per_s(unsigned long long l) { return velocity(l); } -constexpr auto operator"" q_cm_per_s(long double l) { return velocity(l); } +constexpr auto operator"" q_cm_per_s(unsigned long long l) { return speed(l); } +constexpr auto operator"" q_cm_per_s(long double l) { return speed(l); } } // namespace literals diff --git a/src/include/units/physical/dimensions.h b/src/include/units/physical/dimensions.h index e3ff96c9..d312973b 100644 --- a/src/include/units/physical/dimensions.h +++ b/src/include/units/physical/dimensions.h @@ -207,7 +207,7 @@ template concept Volume = QuantityOf; template -concept Velocity = QuantityOf; +concept Speed = QuantityOf; template concept Acceleration = QuantityOf; diff --git a/src/include/units/physical/international/velocity.h b/src/include/units/physical/international/speed.h similarity index 92% rename from src/include/units/physical/international/velocity.h rename to src/include/units/physical/international/speed.h index d45c47d4..da68cbe6 100644 --- a/src/include/units/physical/international/velocity.h +++ b/src/include/units/physical/international/speed.h @@ -22,7 +22,7 @@ #pragma once -#include +#include #include namespace units::physical::international { @@ -32,8 +32,8 @@ struct mile_per_hour : deduced_unit(l); } -constexpr auto operator"" q_mi_per_h(long double l) { return si::velocity(l); } +constexpr auto operator"" q_mi_per_h(unsigned long long l) { return si::speed(l); } +constexpr auto operator"" q_mi_per_h(long double l) { return si::speed(l); } } // namespace literals diff --git a/src/include/units/physical/natural/constants.h b/src/include/units/physical/natural/constants.h index 8f4cdfeb..afcb89de 100644 --- a/src/include/units/physical/natural/constants.h +++ b/src/include/units/physical/natural/constants.h @@ -27,6 +27,6 @@ namespace units::physical::natural { template -inline constexpr auto speed_of_light = velocity(1); +inline constexpr auto speed_of_light = speed(1); } // namespace units::physical::natural diff --git a/src/include/units/physical/natural/dimensions.h b/src/include/units/physical/natural/dimensions.h index b3976bfa..ede5a66c 100644 --- a/src/include/units/physical/natural/dimensions.h +++ b/src/include/units/physical/natural/dimensions.h @@ -42,7 +42,7 @@ using mass = quantity; struct dim_velocity : physical::dim_velocity {}; template -using velocity = quantity; +using speed = quantity; struct dim_acceleration : physical::dim_acceleration {}; template diff --git a/src/include/units/physical/si.h b/src/include/units/physical/si.h index 49037a13..d634167b 100644 --- a/src/include/units/physical/si.h +++ b/src/include/units/physical/si.h @@ -49,6 +49,6 @@ #include "si/resistance.h" #include "si/surface_tension.h" #include "si/thermal_conductivity.h" -#include "si/velocity.h" +#include "si/speed.h" #include "si/voltage.h" #include "si/volume.h" diff --git a/src/include/units/physical/si/acceleration.h b/src/include/units/physical/si/acceleration.h index c1a61242..cdb6bbc5 100644 --- a/src/include/units/physical/si/acceleration.h +++ b/src/include/units/physical/si/acceleration.h @@ -23,7 +23,7 @@ #pragma once #include -#include +#include #include namespace units::physical::si { diff --git a/src/include/units/physical/si/constants.h b/src/include/units/physical/si/constants.h index 720b87dd..750a1d4b 100644 --- a/src/include/units/physical/si/constants.h +++ b/src/include/units/physical/si/constants.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace units::physical::si::si2019 { @@ -48,7 +48,7 @@ template inline constexpr auto avogadro_constant = Rep(6.02214076e23) / substance(1); template -inline constexpr auto speed_of_light = velocity(299'792'458); +inline constexpr auto speed_of_light = speed(299'792'458); template inline constexpr auto hyperfine_structure_transition_frequency = frequency(9'192'631'770); diff --git a/src/include/units/physical/si/momentum.h b/src/include/units/physical/si/momentum.h index eb6cfde0..888e782a 100644 --- a/src/include/units/physical/si/momentum.h +++ b/src/include/units/physical/si/momentum.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include namespace units::physical::si { diff --git a/src/include/units/physical/si/velocity.h b/src/include/units/physical/si/speed.h similarity index 83% rename from src/include/units/physical/si/velocity.h rename to src/include/units/physical/si/speed.h index 8a33fcde..9c3ba933 100644 --- a/src/include/units/physical/si/velocity.h +++ b/src/include/units/physical/si/speed.h @@ -35,17 +35,17 @@ struct dim_velocity : physical::dim_velocity {}; template -using velocity = quantity; +using speed = quantity; inline namespace literals { // mps -constexpr auto operator"" q_m_per_s(unsigned long long l) { return velocity(l); } -constexpr auto operator"" q_m_per_s(long double l) { return velocity(l); } +constexpr auto operator"" q_m_per_s(unsigned long long l) { return speed(l); } +constexpr auto operator"" q_m_per_s(long double l) { return speed(l); } // kmph -constexpr auto operator"" q_km_per_h(unsigned long long l) { return velocity(l); } -constexpr auto operator"" q_km_per_h(long double l) { return velocity(l); } +constexpr auto operator"" q_km_per_h(unsigned long long l) { return speed(l); } +constexpr auto operator"" q_km_per_h(long double l) { return speed(l); } } // namespace literals diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index e08e623c..4627b0ba 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -26,7 +26,7 @@ #include "units/physical/si/frequency.h" #include "units/physical/si/power.h" #include "units/physical/si/pressure.h" -#include "units/physical/si/velocity.h" +#include "units/physical/si/speed.h" #include "units/physical/si/volume.h" #include "units/physical/si/surface_tension.h" #include "units/physical/si/resistance.h" @@ -268,7 +268,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") SECTION("deduced derived unit") { - SECTION("velocity") + SECTION("speed") { const auto q = 20q_km / 2q_h; os << q; diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 905bb3b2..3f98afc1 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -26,7 +26,7 @@ #include "units/physical/international/length.h" #include "units/physical/international/area.h" #include "units/physical/international/volume.h" -#include "units/physical/international/velocity.h" +#include "units/physical/international/speed.h" #include "units/physical/iau/length.h" #include "units/physical/typographic/length.h" #include "units/format.h" @@ -152,7 +152,7 @@ TEST_CASE("fmt::format on synthesized unit symbols", "[text][fmt]") CHECK(fmt::format("{}", 1q_THz) == "1 THz"); } - SECTION("velocity") + SECTION("speed") { CHECK(fmt::format("{}", 1q_m_per_s) == "1 m/s"); CHECK(fmt::format("{}", 1q_km_per_h) == "1 km/h"); diff --git a/test/unit_test/static/cgs_test.cpp b/test/unit_test/static/cgs_test.cpp index 30140e48..bd6e074c 100644 --- a/test/unit_test/static/cgs_test.cpp +++ b/test/unit_test/static/cgs_test.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace { @@ -48,7 +48,7 @@ static_assert(centimetre::symbol == "cm"); /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ -// velocity +// speed static_assert(10q_cm / 5q_s == 2q_cm_per_s); static_assert(10q_cm / 2q_cm_per_s == 5q_s); diff --git a/test/unit_test/static/custom_rep_min_req_test.cpp b/test/unit_test/static/custom_rep_min_req_test.cpp index acb74a08..d9a12ce5 100644 --- a/test/unit_test/static/custom_rep_min_req_test.cpp +++ b/test/unit_test/static/custom_rep_min_req_test.cpp @@ -23,7 +23,7 @@ #include "units/math.h" #include "units/physical/si/area.h" #include "units/physical/si/frequency.h" -#include "units/physical/si/velocity.h" +#include "units/physical/si/speed.h" #include #include @@ -249,30 +249,30 @@ static_assert(length>(quantity_cast(length< // static_assert(length>(length>(expl_expl(2000))).count() == expl_expl(2)); // should not compile (truncating conversion) static_assert(length>(quantity_cast(length>(expl_expl(2000)))).count() == expl_expl(2)); -// static_assert(velocity>(velocity>(72)).count() == impl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(72))).count() == impl(20)); -// static_assert(velocity>(velocity>(expl(72))).count() == expl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl(72)))).count() == expl(20)); -// static_assert(velocity>(velocity>(72)).count() == impl_impl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(72))).count() == impl_impl(20)); -// static_assert(velocity>(velocity>(72)).count() == impl_expl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(72))).count() == impl_expl(20)); -// static_assert(velocity>(velocity>(expl_impl(72))).count() == expl_impl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl_impl(72)))).count() == expl_impl(20)); -// static_assert(velocity>(velocity>(expl_expl(72))).count() == expl_expl(20)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl_expl(72)))).count() == expl_expl(20)); +// static_assert(speed>(speed>(72)).count() == impl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(72))).count() == impl(20)); +// static_assert(speed>(speed>(expl(72))).count() == expl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl(72)))).count() == expl(20)); +// static_assert(speed>(speed>(72)).count() == impl_impl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(72))).count() == impl_impl(20)); +// static_assert(speed>(speed>(72)).count() == impl_expl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(72))).count() == impl_expl(20)); +// static_assert(speed>(speed>(expl_impl(72))).count() == expl_impl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl_impl(72)))).count() == expl_impl(20)); +// static_assert(speed>(speed>(expl_expl(72))).count() == expl_expl(20)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl_expl(72)))).count() == expl_expl(20)); -// static_assert(velocity>(velocity>(20)).count() == impl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(20))).count() == impl(72)); -// static_assert(velocity>(velocity>(expl(20))).count() == expl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl(20)))).count() == expl(72)); -// static_assert(velocity>(velocity>(20)).count() == impl_impl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(20))).count() == impl_impl(72)); -// static_assert(velocity>(velocity>(20)).count() == impl_expl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(20))).count() == impl_expl(72)); -// static_assert(velocity>(velocity>(expl_impl(20))).count() == expl_impl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl_impl(20)))).count() == expl_impl(72)); -// static_assert(velocity>(velocity>(expl_expl(20))).count() == expl_expl(72)); // should not compile (truncating conversion) -static_assert(velocity>(quantity_cast(velocity>(expl_expl(20)))).count() == expl_expl(72)); +// static_assert(speed>(speed>(20)).count() == impl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(20))).count() == impl(72)); +// static_assert(speed>(speed>(expl(20))).count() == expl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl(20)))).count() == expl(72)); +// static_assert(speed>(speed>(20)).count() == impl_impl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(20))).count() == impl_impl(72)); +// static_assert(speed>(speed>(20)).count() == impl_expl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(20))).count() == impl_expl(72)); +// static_assert(speed>(speed>(expl_impl(20))).count() == expl_impl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl_impl(20)))).count() == expl_impl(72)); +// static_assert(speed>(speed>(expl_expl(20))).count() == expl_expl(72)); // should not compile (truncating conversion) +static_assert(speed>(quantity_cast(speed>(expl_expl(20)))).count() == expl_expl(72)); } // namespace diff --git a/test/unit_test/static/dimensions_concepts_test.cpp b/test/unit_test/static/dimensions_concepts_test.cpp index 88689de0..bf3b5796 100644 --- a/test/unit_test/static/dimensions_concepts_test.cpp +++ b/test/unit_test/static/dimensions_concepts_test.cpp @@ -57,8 +57,8 @@ static_assert(!Area>); static_assert(Volume>); static_assert(!Volume>); -static_assert(Velocity>); -static_assert(!Velocity>); +static_assert(Speed>); +static_assert(!Speed>); static_assert(Acceleration>); static_assert(!Acceleration>); diff --git a/test/unit_test/static/math_test.cpp b/test/unit_test/static/math_test.cpp index ab4c04fa..00bdc902 100644 --- a/test/unit_test/static/math_test.cpp +++ b/test/unit_test/static/math_test.cpp @@ -21,7 +21,7 @@ // SOFTWARE. #include "units/physical/si/area.h" -#include "units/physical/si/velocity.h" +#include "units/physical/si/speed.h" #include "units/physical/international/area.h" #include "units/math.h" diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index a5770f2a..9618b0f4 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -23,7 +23,7 @@ #include "units/math.h" #include "units/physical/si/area.h" #include "units/physical/si/frequency.h" -#include "units/physical/si/velocity.h" +#include "units/physical/si/speed.h" #include "units/physical/si/volume.h" #include #include @@ -135,9 +135,9 @@ static_assert( static_assert(std::is_same_v() * 1.0), length>); static_assert(std::is_same_v()), length>); static_assert( - std::is_same_v() * physical::si::time()), length>); + std::is_same_v() * physical::si::time()), length>); static_assert( - std::is_same_v() * physical::si::time()), length, metre>, int>>); + std::is_same_v() * physical::si::time()), length, metre>, int>>); static_assert(std::is_same_v() * physical::si::time()), quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v()), frequency>); @@ -149,9 +149,9 @@ static_assert(std::is_same_v() / 1.0), length() / length()), double>); static_assert(std::is_same_v() / length()), double>); static_assert( - std::is_same_v() / physical::si::time()), velocity>); + std::is_same_v() / physical::si::time()), speed>); static_assert( - std::is_same_v() / physical::si::time()), velocity, metre_per_second>>>); + std::is_same_v() / physical::si::time()), speed, metre_per_second>>>); static_assert(std::is_same_v() / length()), quantity, units::exp>, scaled_unit, unknown_coherent_unit>>>); static_assert(std::is_same_v() % short(1)), length>); @@ -245,7 +245,7 @@ static_assert(1q_km + 1q_m == 1001q_m); static_assert(10q_km / 5q_km == 2); static_assert(10q_km / 2 == 5q_km); -// velocity +// speed static_assert(10q_m / 5q_s == 2q_m_per_s); static_assert(10 / 5q_s * 1q_m == 2q_m_per_s); diff --git a/test/unit_test/static/si_cgs_test.cpp b/test/unit_test/static/si_cgs_test.cpp index 37abe968..87ca9a33 100644 --- a/test/unit_test/static/si_cgs_test.cpp +++ b/test/unit_test/static/si_cgs_test.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ #include #include #include -#include +#include namespace { @@ -49,7 +49,7 @@ using namespace units::physical; static_assert(cgs::length(100) == si::length(1)); static_assert(cgs::mass(1'000) == si::mass(1)); static_assert(cgs::time(1) == si::time(1)); -static_assert(cgs::velocity(100) == si::velocity(1)); +static_assert(cgs::speed(100) == si::speed(1)); static_assert(cgs::area(10000) == si::area(1)); static_assert(cgs::acceleration(100) == si::acceleration(1)); static_assert(cgs::force(100'000) == si::force(1)); @@ -64,7 +64,7 @@ using namespace units::physical::si::literals; static_assert(cgs::length(100) == 1q_m); static_assert(cgs::mass(1'000) == 1q_kg); static_assert(cgs::time(1) == 1q_s); -static_assert(cgs::velocity(100) == 1q_m_per_s); +static_assert(cgs::speed(100) == 1q_m_per_s); static_assert(cgs::acceleration(100) == 1q_m_per_s2); static_assert(cgs::force(100'000) == 1q_N); static_assert(cgs::energy(10'000'000) == 1q_J); @@ -80,7 +80,7 @@ using namespace units::physical::cgs::literals; static_assert(100q_cm == si::length(1)); static_assert(1'000q_g == si::mass(1)); static_assert(1q_s == si::time(1)); -static_assert(100q_cm_per_s == si::velocity(1)); +static_assert(100q_cm_per_s == si::speed(1)); static_assert(100q_Gal == si::acceleration(1)); static_assert(100'000q_dyn == si::force(1)); static_assert(10'000'000q_erg == si::energy(1)); diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index 21f83b1c..e2ea7ecb 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -235,9 +235,9 @@ static_assert(kilogray::symbol == "kGy"); /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ -// velocity +// speed -static_assert(std::is_same_v, metre_per_second>, std::int64_t>>); +static_assert(std::is_same_v, metre_per_second>, std::int64_t>>); static_assert(10q_m / 5q_s == 2q_m_per_s); static_assert(10 / 5q_s * 1q_m == 2q_m_per_s); diff --git a/test/unit_test/static/us_test.cpp b/test/unit_test/static/us_test.cpp index 387dce1d..2256ceb4 100644 --- a/test/unit_test/static/us_test.cpp +++ b/test/unit_test/static/us_test.cpp @@ -23,11 +23,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ static_assert(5q_in + 8q_cm == 207q_mm); /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ -// velocity +// speed static_assert(10.0q_mi / 2q_h == 5q_mi_per_h); diff --git a/test_package/test_package.cpp b/test_package/test_package.cpp index efd7116f..021659bc 100644 --- a/test_package/test_package.cpp +++ b/test_package/test_package.cpp @@ -20,10 +20,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include -constexpr units::Velocity AUTO avg_speed(units::Length AUTO d, units::Time AUTO t) +constexpr units::Speed AUTO avg_speed(units::Length AUTO d, units::Time AUTO t) { return d / t; }