2019-11-02 13:59:11 +01:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
2019-12-09 17:19:58 +01:00
|
|
|
#include <units/physical/cgs/acceleration.h>
|
|
|
|
#include <units/physical/cgs/energy.h>
|
|
|
|
#include <units/physical/cgs/force.h>
|
|
|
|
#include <units/physical/cgs/length.h>
|
|
|
|
#include <units/physical/cgs/mass.h>
|
|
|
|
#include <units/physical/cgs/power.h>
|
|
|
|
#include <units/physical/cgs/pressure.h>
|
|
|
|
#include <units/physical/cgs/time.h>
|
|
|
|
#include <units/physical/cgs/velocity.h>
|
2019-11-02 13:59:11 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-12-09 17:19:58 +01:00
|
|
|
using namespace units;
|
2019-12-11 16:20:08 +01:00
|
|
|
using namespace units::cgs;
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
/* ************** BASE DIMENSIONS **************** */
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
// length
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
static_assert(centimetre::symbol == "cm");
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
// mass
|
2019-11-02 13:59:11 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
// time
|
2019-11-02 13:59:11 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
/* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
// velocity
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
static_assert(10cm / 5s == 2cmps);
|
|
|
|
static_assert(10cm / 2cmps == 5s);
|
|
|
|
static_assert(10cm == 2cmps * 5s);
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
static_assert(detail::unit_text<dim_velocity, centimetre_per_second>() == "cm/s");
|
2019-12-09 17:19:58 +01:00
|
|
|
|
2019-12-11 16:20:08 +01:00
|
|
|
// area
|
|
|
|
static_assert(std::is_same_v<ratio_divide<centimetre::ratio, dimension_unit<dim_length>::ratio>, ratio<1>>);
|
|
|
|
|
2020-01-09 10:03:41 +01:00
|
|
|
static_assert(1cm * 1cm == 1cm2);
|
|
|
|
static_assert(100cm2 / 10cm == 10cm);
|
2019-12-11 16:20:08 +01:00
|
|
|
|
|
|
|
static_assert(detail::unit_text<dim_area, square_centimetre>() == "cm²");
|
|
|
|
|
|
|
|
/* ************** DERIVED DIMENSIONS WITH NAMED UNITS **************** */
|
|
|
|
|
|
|
|
// acceleration
|
|
|
|
|
|
|
|
static_assert(10cmps / 10s == 1Gal);
|
|
|
|
static_assert(10cmps / 1Gal == 10s);
|
|
|
|
static_assert(1Gal * 10s == 10cmps);
|
|
|
|
|
|
|
|
// force
|
|
|
|
|
|
|
|
static_assert(10g * 10Gal == 100dyn);
|
|
|
|
static_assert(100dyn / 10g == 10Gal);
|
|
|
|
static_assert(100dyn / 10Gal == 10g);
|
|
|
|
|
|
|
|
// pressure
|
|
|
|
|
2020-01-09 10:03:41 +01:00
|
|
|
static_assert(10dyn / 10cm2 == 1Ba);
|
|
|
|
static_assert(10dyn / 1Ba == 10cm2);
|
|
|
|
static_assert(1Ba * 10cm2 == 10dyn);
|
2019-12-11 16:20:08 +01:00
|
|
|
|
|
|
|
// energy
|
|
|
|
|
|
|
|
static_assert(10dyn * 10cm == 100_erg);
|
|
|
|
static_assert(100_erg / 10cm == 10dyn);
|
|
|
|
static_assert(100_erg / 10dyn == 10cm);
|
|
|
|
|
|
|
|
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
|
|
|
|
|
|
|
// power
|
|
|
|
|
|
|
|
static_assert(10_erg / 10s == 1_ergps);
|
|
|
|
static_assert(1_ergps * 10s == 10_erg);
|
|
|
|
static_assert(10_erg / 1_ergps == 10s);
|
|
|
|
|
|
|
|
static_assert(detail::unit_text<dim_power, erg_per_second>() == "erg/s");
|
2019-12-09 17:19:58 +01:00
|
|
|
|
|
|
|
}
|