Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2003-2020 Andy Little.
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see http://www.gnu.org/licenses./
|
|
|
|
*/
|
|
|
|
|
2023-05-25 12:47:10 +02:00
|
|
|
#include <mp-units/format.h>
|
|
|
|
#include <mp-units/systems/isq/space_and_time.h>
|
|
|
|
#include <mp-units/systems/si/unit_symbols.h>
|
|
|
|
#include <mp-units/systems/si/units.h>
|
2020-01-14 12:50:30 +01:00
|
|
|
#include <iostream>
|
2021-03-30 13:21:05 +02:00
|
|
|
#include <type_traits>
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
|
|
|
/*
|
2020-01-14 12:50:30 +01:00
|
|
|
get conversion factor from one dimensionally equivalent
|
|
|
|
quantity type to another
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2022-12-29 20:18:48 +01:00
|
|
|
template<mp_units::Quantity Target, mp_units::Quantity Source>
|
2022-11-11 10:33:24 -10:00
|
|
|
requires std::constructible_from<Target, Source>
|
|
|
|
inline constexpr double conversion_factor(Target, Source)
|
2020-01-14 12:50:30 +01:00
|
|
|
{
|
2023-08-30 11:30:35 +02:00
|
|
|
return mp_units::value_cast<Target::unit>(1. * Source::reference).numerical_value();
|
2020-01-14 12:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2022-12-29 20:18:48 +01:00
|
|
|
using namespace mp_units;
|
2023-02-08 21:47:48 -08:00
|
|
|
using namespace mp_units::si::unit_symbols;
|
2020-03-01 14:44:45 +01:00
|
|
|
|
|
|
|
std::cout << "conversion factor in mp-units...\n\n";
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
2023-02-08 21:47:48 -08:00
|
|
|
constexpr auto lengthA = 2.0 * m;
|
2023-08-23 16:46:15 +02:00
|
|
|
constexpr auto lengthB = lengthA.in(mm);
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
2023-06-21 18:05:21 +02:00
|
|
|
std::cout << MP_UNITS_STD_FMT::format("lengthA( {} ) and lengthB( {} )\n", lengthA, lengthB)
|
2020-01-14 12:50:30 +01:00
|
|
|
<< "represent the same length in different units.\n\n";
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
2023-06-21 18:05:21 +02:00
|
|
|
std::cout << MP_UNITS_STD_FMT::format("therefore ratio lengthA / lengthB == {}\n\n", lengthA / lengthB);
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
|
2023-06-21 18:05:21 +02:00
|
|
|
std::cout << MP_UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n",
|
|
|
|
lengthA, lengthB)
|
2023-08-23 17:15:32 +02:00
|
|
|
<< MP_UNITS_STD_FMT::format("lengthB.value( {} ) == lengthA.value( {} ) * conversion_factor( {} )\n",
|
2023-08-30 11:30:35 +02:00
|
|
|
lengthB.numerical_value(), lengthA.numerical_value(),
|
|
|
|
conversion_factor(lengthB, lengthA));
|
Third party examples : add box example
Add si::density quantity header .
Add si::resistance quantity header.
Update si::capacitance header with mF, uF, nF, pF.
Update si::voltage header with mV, uV, nV,pV
Third party example : add capacitor time curve example
Add incoherent length units, TODO move them out from si header.
Third party examples : add clcpp_response showing effectivenes of typed units for physical quantity library
Third party examples : add conversion factor example
Add third party examples to cmake
Third party examples : box example : Add air_density constant for clarity remove explicit this-> and tidy up.
Third party examples : in clcpp response example, change base unit from km to m for single type or all units example.
Third party examples : conversion_factor , add inline constexpr to units_str function.
Third party examples : box_example, change quantity::unit syntax to quantity::unit<> to allow generic(default double) value_type.
examples : remove examples from third party to main examples directory. Update cmake.
physical/si/resistance.hpp : remove underscores from kiloohm etc, UDL collision with 'R' so prefix with underscore
2020-01-06 21:29:05 +00:00
|
|
|
}
|