mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
Some length unit fixed + whitespace cleanup
This commit is contained in:
@@ -27,9 +27,14 @@
|
||||
|
||||
namespace units::iau {
|
||||
|
||||
struct light_year : named_scaled_unit<light_year,"ly",no_prefix,ratio<946073,100000,15>,si::metre> {};
|
||||
struct parsec : named_scaled_unit<parsec,"pc",no_prefix,ratio<1542839,500000,16>,si::metre> {};
|
||||
struct angstrom : named_scaled_unit<angstrom,"angstrom",no_prefix,ratio<1,1,-10>,si::metre> {};
|
||||
// https://en.wikipedia.org/wiki/Light-year
|
||||
struct light_year : named_scaled_unit<light_year, "ly", no_prefix, ratio<9460730472580800>, si::metre> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Parsec
|
||||
struct parsec : named_scaled_unit<parsec, "pc", si::prefix, ratio<30'856'775'814'913'673>, si::metre> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Angstrom
|
||||
struct angstrom : named_scaled_unit<angstrom, "angstrom", no_prefix, ratio<1, 1, -10>, si::metre> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
|
@@ -22,12 +22,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/physical/si/length.h>
|
||||
#include <units/physical/international/length.h>
|
||||
|
||||
namespace units::imperial {
|
||||
|
||||
struct chain : named_scaled_unit<chain,"ch",no_prefix,ratio<502921,250000,1>, si::metre> {};
|
||||
struct rod : named_scaled_unit<rod,"rd",no_prefix, ratio<502921,100000>,si::metre> {};
|
||||
// https://en.wikipedia.org/wiki/Chain_(unit)
|
||||
struct chain : named_scaled_unit<chain, "ch", no_prefix, ratio<22, 1>, international::yard> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Rod_(unit)
|
||||
struct rod : named_scaled_unit<rod, "rd", no_prefix, ratio<1, 4>, chain> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -37,7 +40,6 @@ constexpr auto operator"" ch(long double l) { return si::length<chain, long doub
|
||||
constexpr auto operator"" rd(unsigned long long l) { return si::length<rod, std::int64_t>(l); }
|
||||
constexpr auto operator"" rd(long double l) { return si::length<rod, long double>(l); }
|
||||
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
} // namespace units::imperial
|
||||
|
@@ -25,41 +25,38 @@
|
||||
|
||||
#include <units/physical/si/length.h>
|
||||
|
||||
/*
|
||||
international units of length are defined in terms of the si metre
|
||||
*/
|
||||
|
||||
namespace units::international {
|
||||
|
||||
//international yard
|
||||
//https://en.wikipedia.org/wiki/International_yard_and_pound
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 1'000,-1>, si::metre> {};
|
||||
// international yard
|
||||
// https://en.wikipedia.org/wiki/International_yard_and_pound
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 1'000, -1>, si::metre> {};
|
||||
|
||||
//international foot
|
||||
//https://en.wikipedia.org/wiki/Foot_(unit)#International_foot
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<3'048,1'000,-1>, si::metre> {};
|
||||
// international foot
|
||||
// https://en.wikipedia.org/wiki/Foot_(unit)#International_foot
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
|
||||
|
||||
//https://en.wikipedia.org/wiki/Fathom#International_fathom
|
||||
struct fathom : named_scaled_unit<fathom, "fathom",no_prefix,ratio<1'828,1'000>,si::metre > {};
|
||||
// https://en.wikipedia.org/wiki/Fathom#International_fathom
|
||||
struct fathom : named_scaled_unit<fathom, "fathom", no_prefix, ratio<2>, yard> {};
|
||||
|
||||
//international inch
|
||||
//https://en.wikipedia.org/wiki/Inch#Equivalences
|
||||
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<254,100,-2>, si::metre> {};
|
||||
// international inch
|
||||
// https://en.wikipedia.org/wiki/Inch#Equivalences
|
||||
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<1, 36>, yard> {};
|
||||
|
||||
//intrnational mile
|
||||
//https://en.wikipedia.org/wiki/Mile#International_mile
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<25'146,15'625,3>, si::metre> {};
|
||||
// intrnational mile
|
||||
// https://en.wikipedia.org/wiki/Mile#International_mile
|
||||
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<25'146, 15'625>, si::kilometre> {};
|
||||
|
||||
//international nautical mile
|
||||
//https://en.wikipedia.org/wiki/Mile#Nautical_mile
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile,"mi(naut)",no_prefix, ratio<463,250,3>,si::metre> {};
|
||||
// international nautical mile
|
||||
// https://en.wikipedia.org/wiki/Nautical_mile
|
||||
struct nautical_mile : named_scaled_unit<nautical_mile, "mi(naut)", no_prefix, ratio<1852>, si::metre> {};
|
||||
|
||||
//TODO thou
|
||||
//https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
//struct thou : named_scaled_unit<thou,"thou",no_prefix,ratio<127,50,-5>,si::metre> {};
|
||||
// different name for thou
|
||||
//https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
struct mil : named_scaled_unit<mil,"mil",no_prefix,ratio<127,50,-5>,si::metre> {};
|
||||
// thou
|
||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
struct thou : named_scaled_unit<thou, "thou", no_prefix, ratio<1, 1000>, inch> {};
|
||||
|
||||
// mil - different name for thou
|
||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||
using mil = thou;
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
@@ -87,14 +84,14 @@ constexpr auto operator"" mi(long double l) { return si::length<mile, long doubl
|
||||
constexpr auto operator"" naut_mi(unsigned long long l) { return si::length<nautical_mile, std::int64_t>(l); }
|
||||
constexpr auto operator"" naut_mi(long double l) { return si::length<nautical_mile, long double>(l); }
|
||||
|
||||
//TODO thou
|
||||
//constexpr auto operator"" thou(unsigned long long l) { return si::length<thou, std::int64_t>(l); }
|
||||
//constexpr auto operator"" thou(long double l) { return si::length<thou, long double>(l); }
|
||||
// thou
|
||||
constexpr auto operator"" thou(unsigned long long l) { return si::length<thou, std::int64_t>(l); }
|
||||
constexpr auto operator"" thou(long double l) { return si::length<thou, long double>(l); }
|
||||
|
||||
// mil
|
||||
constexpr auto operator"" mil(unsigned long long l) { return si::length<mil, std::int64_t>(l); }
|
||||
constexpr auto operator"" mil(long double l) { return si::length<mil, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
} // namespace literals
|
||||
|
||||
} //namespace units::international
|
||||
} // namespace units::international
|
||||
|
@@ -32,7 +32,7 @@ namespace units::si {
|
||||
|
||||
struct kilogram_per_metre_cub : unit<kilogram_per_metre_cub> {};
|
||||
|
||||
struct dim_density : physical::dim_density<dim_density, kilogram_per_metre_cub,dim_mass, dim_length> {};
|
||||
struct dim_density : physical::dim_density<dim_density, kilogram_per_metre_cub, dim_mass, dim_length> {};
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using density = quantity<dim_density, U, Rep>;
|
||||
|
@@ -34,7 +34,7 @@ struct centimetre : prefixed_unit<centimetre, centi, metre> {};
|
||||
struct decimetre : prefixed_unit<decimetre, deci, metre> {};
|
||||
struct hectometre : prefixed_unit<hectometre, hecto, metre> {};
|
||||
struct kilometre : prefixed_unit<kilometre, kilo, metre> {};
|
||||
struct femtometre : prefixed_unit<femtometre,femto,metre> {};
|
||||
struct femtometre : prefixed_unit<femtometre, femto, metre> {};
|
||||
|
||||
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", no_prefix, ratio<149'597'870'700>, metre> {};
|
||||
|
||||
|
@@ -27,26 +27,27 @@
|
||||
|
||||
namespace units::typographic {
|
||||
|
||||
struct pica_comp : named_scaled_unit<pica_comp,"pica(comp)",no_prefix,ratio<4233333,1000000,-3>,si::metre> {};
|
||||
struct pica_prn : named_scaled_unit<pica_prn,"pica(prn)",no_prefix,ratio<2108759,500000,-3>,si::metre> {};
|
||||
struct point_comp : named_scaled_unit<point_comp,"point(comp)",no_prefix,ratio<1763889,500000,-4>,si::metre> {};
|
||||
struct point_prn : named_scaled_unit<point_prn,"point(prn)", no_prefix, ratio<1757299,500000,-4>,si::metre> {};
|
||||
// TODO Conflicts with (https://en.wikipedia.org/wiki/Pica_(typography)), verify correctness of below conversion factors and provide hyperlinks to definitions
|
||||
struct pica_comp : named_scaled_unit<pica_comp, "pica(comp)", no_prefix, ratio<4233333, 1000000, -3>, si::metre> {};
|
||||
struct pica_prn : named_scaled_unit<pica_prn, "pica(prn)", no_prefix, ratio<2108759, 500000, -3>, si::metre> {};
|
||||
struct point_comp : named_scaled_unit<point_comp, "point(comp)", no_prefix, ratio<1763889, 500000, -4>, si::metre> {};
|
||||
struct point_prn : named_scaled_unit<point_prn, "point(prn)", no_prefix, ratio<1757299, 500000, -4>, si::metre> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// pica comp
|
||||
// pica comp
|
||||
constexpr auto operator"" pica_comp(unsigned long long l) { return si::length<pica_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" pica_comp(long double l) { return si::length<pica_comp, long double>(l); }
|
||||
|
||||
// pica prn
|
||||
// pica prn
|
||||
constexpr auto operator"" pica_prn(unsigned long long l) { return si::length<pica_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" pica_prn(long double l) { return si::length<pica_prn, long double>(l); }
|
||||
|
||||
// point comp
|
||||
// point comp
|
||||
constexpr auto operator"" point_comp(unsigned long long l) { return si::length<point_comp, std::int64_t>(l); }
|
||||
constexpr auto operator"" point_comp(long double l) { return si::length<point_comp, long double>(l); }
|
||||
|
||||
// point prn
|
||||
// point prn
|
||||
constexpr auto operator"" point_prn(unsigned long long l) { return si::length<point_prn, std::int64_t>(l); }
|
||||
constexpr auto operator"" point_prn(long double l) { return si::length<point_prn, long double>(l); }
|
||||
|
||||
|
@@ -26,19 +26,16 @@
|
||||
|
||||
namespace units::us {
|
||||
|
||||
//https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot
|
||||
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
//struct foot : named_scaled_unit<foot,"ft(us)",no_prefix,ratio<3'048,1'000,-1>, si::metre> {};
|
||||
//################### causes integer overflow when converting for volume #######################
|
||||
struct foot : named_scaled_unit<foot,"ft(us)",no_prefix,ratio<1'524'003,5,-6>, si::metre> {};
|
||||
//#############################################################################################
|
||||
// https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct foot : named_scaled_unit<foot, "ft(us)", no_prefix, ratio<1'200, 3'937>, si::metre> {};
|
||||
|
||||
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct fathom : named_scaled_unit<fathom,"fathom(us)",no_prefix,ratio<6,1>,us::foot> {};
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct fathom : named_scaled_unit<fathom, "fathom(us)", no_prefix, ratio<6>, foot> {};
|
||||
|
||||
//https://en.wikipedia.org/wiki/Mile#U.S._survey_mile
|
||||
//https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct mile : named_scaled_unit<mile,"mi(us)",no_prefix,ratio<5280,1000,3>,us::foot> {};
|
||||
// https://en.wikipedia.org/wiki/Mile#U.S._survey_mile
|
||||
// https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
||||
struct mile : named_scaled_unit<mile, "mi(us)", no_prefix, ratio<5280>, us::foot> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
|
Reference in New Issue
Block a user