mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
added some units for the foot-pound-second system and the static tests
This commit is contained in:
45
src/include/units/physical/fps/acceleration.h
Normal file
45
src/include/units/physical/fps/acceleration.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/speed.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
struct foot_per_second_sq : unit<foot_per_second_sq> {};
|
||||
struct dim_acceleration : physical::dim_acceleration<dim_acceleration, foot_per_second_sq, dim_length, dim_time> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using acceleration = quantity<dim_acceleration, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// ft_per_s2
|
||||
constexpr auto operator"" q_ft_per_s2(unsigned long long l) { return acceleration<foot_per_second_sq, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_per_s2(long double l) { return acceleration<foot_per_second_sq, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
47
src/include/units/physical/fps/area.h
Normal file
47
src/include/units/physical/fps/area.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/length.h>
|
||||
// #include <units/physical/si/area.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
struct square_foot : unit<square_foot> {};
|
||||
struct dim_area : physical::dim_area<dim_area, square_foot, dim_length> {};
|
||||
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using area = quantity<dim_area, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// fm2
|
||||
constexpr auto operator"" q_ft2(unsigned long long l) { return area<square_foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft2(long double l) { return area<square_foot, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace units::physical::fps
|
54
src/include/units/physical/fps/energy.h
Normal file
54
src/include/units/physical/fps/energy.h
Normal file
@@ -0,0 +1,54 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/force.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot-poundal
|
||||
struct foot_poundal : unit<foot_poundal> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot-pound_(energy)
|
||||
struct foot_pound_force : named_scaled_unit<foot_poundal, "lbf", no_prefix, ratio<32'174'049, 1'000'000>, foot_poundal> {};
|
||||
|
||||
struct dim_energy : physical::dim_energy<dim_energy, foot_poundal, dim_force, dim_length> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using energy = quantity<dim_energy, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
constexpr auto operator"" q_ft_pdl(unsigned long long l) { return energy<foot_poundal, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_pdl(long double l) { return energy<foot_poundal, long double>(l); }
|
||||
|
||||
// foot_pound force
|
||||
constexpr auto operator"" q_ft_lbf(unsigned long long l) { return energy<foot_pound_force, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_lbf(long double l) { return energy<foot_pound_force, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
58
src/include/units/physical/fps/force.h
Normal file
58
src/include/units/physical/fps/force.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/acceleration.h>
|
||||
#include <units/physical/fps/mass.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Poundal
|
||||
struct poundal : named_unit<poundal, "pdl", no_prefix> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(force)
|
||||
struct pound_force : named_scaled_unit<pound_force, "ftlbf", no_prefix, ratio<32'174'049, 1'000'000>, poundal> {};
|
||||
|
||||
|
||||
|
||||
struct dim_force : physical::dim_force<dim_force, poundal, dim_mass, dim_acceleration> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using force = quantity<dim_force, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// poundal
|
||||
constexpr auto operator"" q_pdl(unsigned long long l) { return force<poundal, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pdl(long double l) { return force<poundal, long double>(l); }
|
||||
|
||||
// pound force
|
||||
constexpr auto operator"" q_lbf(unsigned long long l) { return force<pound_force, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_lbf(long double l) { return force<pound_force, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
47
src/include/units/physical/fps/length.h
Normal file
47
src/include/units/physical/fps/length.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/length.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot_(unit)
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<3'048, 1'000, -1>, si::metre> {};
|
||||
|
||||
struct dim_length : physical::dim_length<foot> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using length = quantity<dim_length, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// ft
|
||||
constexpr auto operator"" q_ft(unsigned long long l) { return length<foot, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft(long double l) { return length<foot, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace units::physical::fps
|
47
src/include/units/physical/fps/mass.h
Normal file
47
src/include/units/physical/fps/mass.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/mass.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(mass)
|
||||
struct pound : named_scaled_unit<pound, "lb", no_prefix, ratio<45'359'237, 100'000'000>, si::kilogram> {};
|
||||
|
||||
struct dim_mass : physical::dim_mass<pound> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using mass = quantity<dim_mass, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// g
|
||||
constexpr auto operator"" q_lb(unsigned long long l) { return mass<pound, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_lb(long double l) { return mass<pound, long double>(l); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace units::physical::fps
|
55
src/include/units/physical/fps/power.h
Normal file
55
src/include/units/physical/fps/power.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/energy.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
struct foot_poundal_per_second : unit<foot_poundal_per_second> {};
|
||||
|
||||
struct foot_pound_force_per_second : scaled_unit<ratio<32'174'049, 1'000'000>, foot_poundal_per_second> {};
|
||||
|
||||
|
||||
struct dim_power : physical::dim_power<dim_power, foot_poundal_per_second, dim_energy, dim_time> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using power = quantity<dim_power, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// foot pound force per second
|
||||
constexpr auto operator"" q_ft_pdl_per_s(unsigned long long l) { return power<foot_poundal_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_pdl_per_s(long double l) { return power<foot_poundal_per_second, long double>(l); }
|
||||
|
||||
|
||||
// foot pound force per second
|
||||
constexpr auto operator"" q_ft_lbf_per_s(unsigned long long l) { return power<foot_pound_force_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_lbf_per_s(long double l) { return power<foot_pound_force_per_second, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
56
src/include/units/physical/fps/pressure.h
Normal file
56
src/include/units/physical/fps/pressure.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/area.h>
|
||||
#include <units/physical/fps/force.h>
|
||||
#include <units/physical/si/prefixes.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
struct poundal_per_foot_sq : unit<poundal_per_foot_sq> {};
|
||||
|
||||
struct pound_force_per_foot_sq : named_scaled_unit<pound_force_per_foot_sq, "lbf ft2", si::prefix, ratio<32'174'049, 1'000'000>, poundal_per_foot_sq> {};
|
||||
|
||||
|
||||
struct dim_pressure : physical::dim_pressure<dim_pressure, poundal_per_foot_sq, dim_force, dim_area> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using pressure = quantity<dim_pressure, U, Rep>;
|
||||
|
||||
struct pound_force_per_inch_sq : named_scaled_unit<pound_force_per_inch_sq, "psi", si::prefix, ratio<1, 144>, pound_force_per_foot_sq> {};
|
||||
|
||||
inline namespace literals {
|
||||
// Poundal per square foot
|
||||
constexpr auto operator"" q_pdl_per_ft2(unsigned long long l) { return pressure<poundal_per_foot_sq, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_pdl_per_ft2(long double l) { return pressure<poundal_per_foot_sq, long double>(l); }
|
||||
|
||||
// Pounds per square inch
|
||||
constexpr auto operator"" q_psi(unsigned long long l) { return pressure<pound_force_per_inch_sq, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_psi(long double l) { return pressure<pound_force_per_inch_sq, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
46
src/include/units/physical/fps/speed.h
Normal file
46
src/include/units/physical/fps/speed.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/fps/length.h>
|
||||
#include <units/physical/fps/time.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
struct foot_per_second : unit<foot_per_second> {};
|
||||
struct dim_speed : physical::dim_speed<dim_speed, foot_per_second, dim_length, dim_time> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using speed = quantity<dim_speed, U, Rep>;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// cmps
|
||||
constexpr auto operator"" q_ft_per_s(unsigned long long l) { return speed<foot_per_second, std::int64_t>(l); }
|
||||
constexpr auto operator"" q_ft_per_s(long double l) { return speed<foot_per_second, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::physical::fps
|
42
src/include/units/physical/fps/time.h
Normal file
42
src/include/units/physical/fps/time.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/dimensions.h>
|
||||
#include <units/physical/si/time.h>
|
||||
#include <units/quantity.h>
|
||||
|
||||
namespace units::physical::fps {
|
||||
|
||||
using si::second;
|
||||
|
||||
using si::dim_time;
|
||||
using si::time;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
using si::literals::operator"" q_s;
|
||||
|
||||
}
|
||||
|
||||
} // namespace units::physical::fps
|
@@ -28,11 +28,13 @@ add_library(unit_tests_static
|
||||
dimension_op_test.cpp
|
||||
dimensions_concepts_test.cpp
|
||||
fixed_string_test.cpp
|
||||
fps_test.cpp
|
||||
math_test.cpp
|
||||
quantity_test.cpp
|
||||
ratio_test.cpp
|
||||
si_test.cpp
|
||||
si_cgs_test.cpp
|
||||
si_fps_test.cpp
|
||||
symbol_text_test.cpp
|
||||
type_list_test.cpp
|
||||
unit_test.cpp
|
||||
|
102
test/unit_test/static/fps_test.cpp
Normal file
102
test/unit_test/static/fps_test.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
#include <units/physical/fps/acceleration.h>
|
||||
#include <units/physical/fps/energy.h>
|
||||
#include <units/physical/fps/force.h>
|
||||
#include <units/physical/fps/length.h>
|
||||
#include <units/physical/fps/mass.h>
|
||||
#include <units/physical/fps/power.h>
|
||||
#include <units/physical/fps/pressure.h>
|
||||
#include <units/physical/fps/time.h>
|
||||
#include <units/physical/fps/speed.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::physical::fps;
|
||||
|
||||
/* ************** BASE DIMENSIONS **************** */
|
||||
|
||||
// length
|
||||
|
||||
static_assert(foot::symbol == "ft");
|
||||
|
||||
// mass
|
||||
|
||||
// time
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
||||
|
||||
// speed
|
||||
|
||||
static_assert(10q_ft / 5q_s == 2q_ft_per_s);
|
||||
static_assert(10q_ft / 2q_ft_per_s == 5q_s);
|
||||
static_assert(10q_ft == 2q_ft_per_s * 5q_s);
|
||||
|
||||
static_assert(detail::unit_text<dim_speed, foot_per_second>() == "ft/s");
|
||||
|
||||
// area
|
||||
static_assert(std::is_same_v<ratio_divide<foot::ratio, dimension_unit<dim_length>::ratio>, ratio<1>>);
|
||||
|
||||
static_assert(1q_ft * 1q_ft == 1q_ft2);
|
||||
static_assert(100q_ft2 / 10q_ft == 10q_ft);
|
||||
|
||||
static_assert(detail::unit_text<dim_area, square_foot>() == basic_symbol_text("ft²", "ft^2"));
|
||||
|
||||
/* ************** DERIVED DIMENSIONS WITH NAMED UNITS **************** */
|
||||
|
||||
// acceleration
|
||||
|
||||
static_assert(10q_ft_per_s / 10q_s == 1q_ft_per_s2);
|
||||
static_assert(10q_ft_per_s / 1q_ft_per_s2 == 10q_s);
|
||||
static_assert(1q_ft_per_s2 * 10q_s == 10q_ft_per_s);
|
||||
|
||||
// force
|
||||
|
||||
static_assert(10q_lb * 10q_ft_per_s2 == 100q_pdl);
|
||||
static_assert(100q_pdl / 10q_lb == 10q_ft_per_s2);
|
||||
static_assert(100q_pdl / 10q_ft_per_s2 == 10q_lb);
|
||||
|
||||
// pressure
|
||||
static_assert(10q_pdl / 10q_ft2 == 1q_pdl_per_ft2);
|
||||
static_assert(10q_pdl / 1q_pdl_per_ft2 == 10q_ft2);
|
||||
static_assert(1q_pdl_per_ft2 * 10q_ft2 == 10q_pdl);
|
||||
|
||||
// energy
|
||||
|
||||
static_assert(10q_pdl * 10q_ft == 100q_ft_pdl);
|
||||
static_assert(100q_ft_pdl / 10q_ft == 10q_pdl);
|
||||
static_assert(100q_ft_pdl / 10q_pdl == 10q_ft);
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
||||
|
||||
// power
|
||||
|
||||
static_assert(10q_ft_pdl / 10q_s == 1q_ft_pdl_per_s);
|
||||
static_assert(1q_ft_pdl_per_s * 10q_s == 10q_ft_pdl);
|
||||
static_assert(10q_ft_pdl / 1q_ft_pdl_per_s == 10q_s);
|
||||
|
||||
// static_assert(detail::unit_text<dim_power, foot_pound_force_per_second>() == "ft_lbf/s");
|
||||
|
||||
}
|
165
test/unit_test/static/si_fps_test.cpp
Normal file
165
test/unit_test/static/si_fps_test.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Mateusz Pusz
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
#include <units/physical/fps/acceleration.h>
|
||||
#include <units/physical/fps/area.h>
|
||||
#include <units/physical/fps/energy.h>
|
||||
#include <units/physical/fps/force.h>
|
||||
#include <units/physical/fps/length.h>
|
||||
#include <units/physical/fps/mass.h>
|
||||
#include <units/physical/fps/power.h>
|
||||
#include <units/physical/fps/pressure.h>
|
||||
#include <units/physical/fps/time.h>
|
||||
#include <units/physical/fps/speed.h>
|
||||
#include <units/physical/si/acceleration.h>
|
||||
#include <units/physical/si/area.h>
|
||||
#include <units/physical/si/energy.h>
|
||||
#include <units/physical/si/force.h>
|
||||
#include <units/physical/si/length.h>
|
||||
#include <units/physical/si/mass.h>
|
||||
#include <units/physical/si/power.h>
|
||||
#include <units/physical/si/pressure.h>
|
||||
#include <units/physical/si/time.h>
|
||||
#include <units/physical/si/speed.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units::physical;
|
||||
|
||||
static_assert(fps::length<fps::foot>(1) == si::length<si::metre>(0.3048));
|
||||
static_assert(fps::mass<fps::pound>(1) == si::mass<si::kilogram>(0.45359237));
|
||||
static_assert(fps::time<fps::second>(1) == si::time<si::second>(1));
|
||||
static_assert(fps::speed<fps::foot_per_second>(1) == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(fps::area<fps::square_foot>(1) == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(fps::acceleration<fps::foot_per_second_sq>(1) == si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(fps::force<fps::poundal>(1) >= si::force<si::newton>(0.138254) &&
|
||||
fps::force<fps::poundal>(1) <= si::force<si::newton>(0.138256));
|
||||
static_assert(fps::energy<fps::foot_poundal>(1) >= si::energy<si::joule>(0.042140110093804) &&
|
||||
fps::energy<fps::foot_poundal>(1) <= si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(fps::power<fps::foot_poundal_per_second>(1) >= si::power<si::watt>(0.042140110093804) &&
|
||||
fps::power<fps::foot_poundal_per_second>(1) <= si::power<si::watt>(0.042140110093806));
|
||||
static_assert(fps::pressure<fps::poundal_per_foot_sq>(1) >= si::pressure<si::pascal>(1.4881639435) &&
|
||||
fps::pressure<fps::poundal_per_foot_sq>(1) <= si::pressure<si::pascal>(1.4881639437));
|
||||
|
||||
namespace si_literals {
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
|
||||
static_assert(fps::length<fps::foot>(1) == 0.3048q_m);
|
||||
static_assert(fps::mass<fps::pound>(1) == 0.45359237q_kg);
|
||||
static_assert(fps::time<fps::second>(1) == 1q_s);
|
||||
static_assert(fps::speed<fps::foot_per_second>(1) == 0.3048q_m_per_s);
|
||||
static_assert(fps::area<fps::square_foot>(1) == 0.09290304q_m2);
|
||||
static_assert(fps::acceleration<fps::foot_per_second_sq>(1) == 0.3048q_m_per_s2);
|
||||
static_assert(fps::force<fps::poundal>(1) >= 0.138254q_N &&
|
||||
fps::force<fps::poundal>(1) <= 0.138256q_N);
|
||||
static_assert(fps::energy<fps::foot_poundal>(1) >= 0.042140110093804q_J &&
|
||||
fps::energy<fps::foot_poundal>(1) <= 0.042140110093806q_J);
|
||||
static_assert(fps::power<fps::foot_poundal_per_second>(1) >= 0.042140110093804q_W &&
|
||||
fps::power<fps::foot_poundal_per_second>(1) <= 0.042140110093806q_W);
|
||||
static_assert(fps::pressure<fps::poundal_per_foot_sq>(1) >= 1.4881639435q_Pa &&
|
||||
fps::pressure<fps::poundal_per_foot_sq>(1) <= 1.4881639437q_Pa);
|
||||
}
|
||||
|
||||
namespace fps_literals {
|
||||
|
||||
using namespace units::physical::fps::literals;
|
||||
|
||||
static_assert(1q_ft == si::length<si::metre>(0.3048));
|
||||
static_assert(1q_lb == si::mass<si::kilogram>(0.45359237));
|
||||
static_assert(1q_s == si::time<si::second>(1));
|
||||
static_assert(1q_ft_per_s == si::speed<si::metre_per_second>(0.3048));
|
||||
static_assert(1q_ft2 == si::area<si::square_metre>(0.09290304));
|
||||
static_assert(1q_ft_per_s2 == si::acceleration<si::metre_per_second_sq>(0.3048));
|
||||
static_assert(1q_pdl >= si::force<si::newton>(0.138254) &&
|
||||
1q_pdl <= si::force<si::newton>(0.138256));
|
||||
static_assert(1q_ft_pdl >= si::energy<si::joule>(0.042140110093804) &&
|
||||
1q_ft_pdl <= si::energy<si::joule>(0.042140110093806));
|
||||
static_assert(1q_ft_pdl_per_s >= si::power<si::watt>(0.042140110093804) &&
|
||||
1q_ft_pdl_per_s <= si::power<si::watt>(0.042140110093806));
|
||||
static_assert(1q_pdl_per_ft2>= si::pressure<si::pascal>(1.4881639435) &&
|
||||
1q_pdl_per_ft2 <= si::pressure<si::pascal>(1.4881639437));
|
||||
}
|
||||
|
||||
namespace fps_plus_si_literals {
|
||||
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::fps::literals;
|
||||
|
||||
// static_assert(100q_cm == 1q_m); // ambiguous
|
||||
// static_assert(1'000q_g == 1q_kg); // ambiguous
|
||||
static_assert(1q_ft == 0.3048q_m);
|
||||
static_assert(1q_lb == 0.45359237q_kg);
|
||||
static_assert(1q_s == 1q_s);
|
||||
static_assert(1q_ft_per_s == 0.3048q_m_per_s);
|
||||
static_assert(1q_ft2 == 0.09290304q_m2);
|
||||
static_assert(1q_ft_per_s2 == 0.3048q_m_per_s2);
|
||||
static_assert(1q_pdl >= 0.138254q_N &&
|
||||
1q_pdl <= 0.138256q_N);
|
||||
static_assert(1q_ft_pdl >= 0.042140110093804q_J &&
|
||||
1q_ft_pdl <= 0.042140110093806q_J);
|
||||
static_assert(1q_ft_pdl_per_s >= 0.042140110093804q_W &&
|
||||
1q_ft_pdl_per_s <= 0.042140110093806q_W);
|
||||
static_assert(1q_pdl_per_ft2>= 1.4881639435q_Pa &&
|
||||
1q_pdl_per_ft2 <=1.4881639437q_Pa);
|
||||
|
||||
}
|
||||
|
||||
namespace cgs_test {
|
||||
|
||||
using namespace units::physical::fps::literals;
|
||||
|
||||
// addition
|
||||
|
||||
// static_assert(si::length<si::metre>(1) + 1q_ft == si::length<si::metre>(1.3048)); // should not compile (different dimensions)
|
||||
// static_assert(1q_ft / 0.3048 + si::length<si::metre>(1) == si::length<si::metre>(1.3048)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(1q_ft / 0.3048) + si::length<si::metre>(1) == si::length<si::metre>(2)); // 1 m in ft + 1 m
|
||||
static_assert(si::length<si::metre>(1) + quantity_cast<si::length<si::metre>>(1q_ft / 0.3048) == si::length<si::metre>(2)); // 1 m + 1 m in ft
|
||||
static_assert(1q_ft + quantity_cast<fps::length<fps::foot>>(si::length<si::metre>(0.3048)) == 2q_ft); // 1 ft + 1 ft in m
|
||||
static_assert(quantity_cast<fps::length<fps::foot>>(si::length<si::metre>(0.3048)) + 1q_ft == 2q_ft); // 1 ft in m + 1 ft
|
||||
|
||||
// substraction
|
||||
|
||||
// static_assert(1q_ft - si::length<si::metre>(1) == -si::length<si::metre>(0.6952)); // should not compile (different dimensions)
|
||||
// static_assert(si::length<si::metre>(1) - 1q_ft == si::length<si::metre>(0.6952)); // should not compile (different dimensions)
|
||||
static_assert(quantity_cast<si::length<si::metre>>(6.q_ft) - si::length<si::metre>(1) == si::length<si::metre>(0.8288)); // 6 ft in m - 1 m = ... m
|
||||
static_assert(si::length<si::metre>(5) - quantity_cast<si::length<si::metre>>(6q_ft) == si::length<si::metre>(3.1712)); // 5 m - 6 ft in m = ...
|
||||
static_assert(6.q_ft - quantity_cast<fps::length<fps::foot>>(si::length<si::metre>(0.3048)) == 5.q_ft); // 6 ft - 1 ft in m = 5 ft
|
||||
static_assert(quantity_cast<fps::length<fps::foot>>(si::length<si::metre>(1.8288)) - 1.q_ft == 5.q_ft); // 6 ft in m - 1 ft = 5 ft
|
||||
|
||||
// multiplication
|
||||
|
||||
// static_assert(2q_ft * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192)); // should not compile (unknown dimension)
|
||||
// static_assert(quantity_cast<si::length<si::metre>>(2.q_ft) * si::length<si::metre>(2) == si::area<si::square_metre>(1.2192));
|
||||
static_assert(quantity_cast<si::length<si::metre>>(2.q_ft) * si::length<si::metre>(0.6096) == si::area<si::square_metre>(0.371612160)); // 2 ft * 2 ft == 4 sq ft
|
||||
static_assert(2.q_ft * quantity_cast<fps::length<fps::foot>>(si::length<si::metre>(0.6096)) == 4.q_ft2);
|
||||
|
||||
// division
|
||||
|
||||
// static_assert(si::area<si::square_metre>(4) / 200q_cm == si::length<si::metre>(2)); // should not compile (unknown dimension)
|
||||
static_assert(si::area<si::square_metre>(1.48644864) / quantity_cast<si::length<si::metre>>(4q_ft) == si::length<si::metre>(1.2192)); // 16 ft2 / 4 ft = 4 ft
|
||||
static_assert(quantity_cast<fps::area<fps::square_foot>>(si::area<si::square_metre>(1.48644864)) / 4.q_ft == 4.q_ft); // 16 ft2 / 4 ft = 4 ft
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user