forked from mpusz/mp-units
Some length unit fixed + whitespace cleanup
This commit is contained in:
@@ -27,8 +27,13 @@
|
|||||||
|
|
||||||
namespace units::iau {
|
namespace units::iau {
|
||||||
|
|
||||||
struct light_year : named_scaled_unit<light_year,"ly",no_prefix,ratio<946073,100000,15>,si::metre> {};
|
// https://en.wikipedia.org/wiki/Light-year
|
||||||
struct parsec : named_scaled_unit<parsec,"pc",no_prefix,ratio<1542839,500000,16>,si::metre> {};
|
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> {};
|
struct angstrom : named_scaled_unit<angstrom, "angstrom", no_prefix, ratio<1, 1, -10>, si::metre> {};
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
@@ -22,12 +22,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <units/physical/si/length.h>
|
#include <units/physical/international/length.h>
|
||||||
|
|
||||||
namespace units::imperial {
|
namespace units::imperial {
|
||||||
|
|
||||||
struct chain : named_scaled_unit<chain,"ch",no_prefix,ratio<502921,250000,1>, si::metre> {};
|
// https://en.wikipedia.org/wiki/Chain_(unit)
|
||||||
struct rod : named_scaled_unit<rod,"rd",no_prefix, ratio<502921,100000>,si::metre> {};
|
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 {
|
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(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); }
|
constexpr auto operator"" rd(long double l) { return si::length<rod, long double>(l); }
|
||||||
|
|
||||||
|
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
|
|
||||||
} // namespace units::si
|
} // namespace units::imperial
|
||||||
|
@@ -25,10 +25,6 @@
|
|||||||
|
|
||||||
#include <units/physical/si/length.h>
|
#include <units/physical/si/length.h>
|
||||||
|
|
||||||
/*
|
|
||||||
international units of length are defined in terms of the si metre
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace units::international {
|
namespace units::international {
|
||||||
|
|
||||||
// international yard
|
// international yard
|
||||||
@@ -37,29 +33,30 @@ struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio<9'144, 1'000,-1>, s
|
|||||||
|
|
||||||
// international foot
|
// international foot
|
||||||
// https://en.wikipedia.org/wiki/Foot_(unit)#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> {};
|
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio<1, 3>, yard> {};
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Fathom#International_fathom
|
// https://en.wikipedia.org/wiki/Fathom#International_fathom
|
||||||
struct fathom : named_scaled_unit<fathom, "fathom",no_prefix,ratio<1'828,1'000>,si::metre > {};
|
struct fathom : named_scaled_unit<fathom, "fathom", no_prefix, ratio<2>, yard> {};
|
||||||
|
|
||||||
// international inch
|
// international inch
|
||||||
// https://en.wikipedia.org/wiki/Inch#Equivalences
|
// https://en.wikipedia.org/wiki/Inch#Equivalences
|
||||||
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<254,100,-2>, si::metre> {};
|
struct inch : named_scaled_unit<inch, "in", no_prefix, ratio<1, 36>, yard> {};
|
||||||
|
|
||||||
// intrnational mile
|
// intrnational mile
|
||||||
// https://en.wikipedia.org/wiki/Mile#International_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> {};
|
struct mile : named_scaled_unit<mile, "mi", no_prefix, ratio<25'146, 15'625>, si::kilometre> {};
|
||||||
|
|
||||||
// international nautical mile
|
// international nautical mile
|
||||||
//https://en.wikipedia.org/wiki/Mile#Nautical_mile
|
// https://en.wikipedia.org/wiki/Nautical_mile
|
||||||
struct nautical_mile : named_scaled_unit<nautical_mile,"mi(naut)",no_prefix, ratio<463,250,3>,si::metre> {};
|
struct nautical_mile : named_scaled_unit<nautical_mile, "mi(naut)", no_prefix, ratio<1852>, si::metre> {};
|
||||||
|
|
||||||
//TODO thou
|
// thou
|
||||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||||
//struct thou : named_scaled_unit<thou,"thou",no_prefix,ratio<127,50,-5>,si::metre> {};
|
struct thou : named_scaled_unit<thou, "thou", no_prefix, ratio<1, 1000>, inch> {};
|
||||||
// different name for thou
|
|
||||||
|
// mil - different name for thou
|
||||||
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
// https://en.wikipedia.org/wiki/Thousandth_of_an_inch
|
||||||
struct mil : named_scaled_unit<mil,"mil",no_prefix,ratio<127,50,-5>,si::metre> {};
|
using mil = thou;
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
@@ -87,9 +84,9 @@ 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(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); }
|
constexpr auto operator"" naut_mi(long double l) { return si::length<nautical_mile, long double>(l); }
|
||||||
|
|
||||||
//TODO thou
|
// thou
|
||||||
//constexpr auto operator"" thou(unsigned long long l) { return si::length<thou, std::int64_t>(l); }
|
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); }
|
constexpr auto operator"" thou(long double l) { return si::length<thou, long double>(l); }
|
||||||
|
|
||||||
// mil
|
// mil
|
||||||
constexpr auto operator"" mil(unsigned long long l) { return si::length<mil, std::int64_t>(l); }
|
constexpr auto operator"" mil(unsigned long long l) { return si::length<mil, std::int64_t>(l); }
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
namespace units::typographic {
|
namespace units::typographic {
|
||||||
|
|
||||||
|
// 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_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 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_comp : named_scaled_unit<point_comp, "point(comp)", no_prefix, ratio<1763889, 500000, -4>, si::metre> {};
|
||||||
|
@@ -28,17 +28,14 @@ namespace units::us {
|
|||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Foot_(unit)#US_survey_foot
|
// 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
|
// 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> {};
|
struct foot : named_scaled_unit<foot, "ft(us)", no_prefix, ratio<1'200, 3'937>, 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://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors#B6
|
// 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> {};
|
struct fathom : named_scaled_unit<fathom, "fathom(us)", no_prefix, ratio<6>, foot> {};
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/Mile#U.S._survey_mile
|
// 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
|
// 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> {};
|
struct mile : named_scaled_unit<mile, "mi(us)", no_prefix, ratio<5280>, us::foot> {};
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user