WPILibC++ 2024.3.2
density.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5// Copyright (c) 2016 Nic Holthaus
6//
7// The MIT License (MIT)
8//
9// Permission is hereby granted, free of charge, to any person obtaining a copy
10// of this software and associated documentation files (the "Software"), to deal
11// in the Software without restriction, including without limitation the rights
12// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13// copies of the Software, and to permit persons to whom the Software is
14// furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included in
17// all copies or substantial portions of the Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25// SOFTWARE.
26
27#pragma once
28
29#include "units/base.h"
30#include "units/mass.h"
31#include "units/volume.h"
32
33namespace units {
34/**
35 * @namespace units::density
36 * @brief namespace for unit types and containers representing density values
37 * @details The SI unit for density is `kilograms_per_cubic_meter`, and the
38 * corresponding `base_unit` category is `density_unit`.
39 * @anchor densityContainers
40 * @sa See unit_t for more information on unit type containers.
41 */
42#if !defined(DISABLE_PREDEFINED_UNITS) || \
43 defined(ENABLE_PREDEFINED_DENSITY_UNITS)
44UNIT_ADD(density, kilograms_per_cubic_meter, kilograms_per_cubic_meter,
45 kg_per_cu_m, unit<std::ratio<1>, units::category::density_unit>)
47 compound_unit<mass::grams, inverse<volume::milliliter>>)
48UNIT_ADD(density, kilograms_per_liter, kilograms_per_liter, kg_per_L,
49 unit<std::ratio<1>,
50 compound_unit<mass::grams, inverse<volume::milliliter>>>)
52 compound_unit<mass::ounces, inverse<volume::cubic_foot>>)
53UNIT_ADD(density, ounces_per_cubic_inch, ounces_per_cubic_inch, oz_per_cu_in,
54 compound_unit<mass::ounces, inverse<volume::cubic_inch>>)
56 compound_unit<mass::ounces, inverse<volume::gallon>>)
57UNIT_ADD(density, pounds_per_cubic_foot, pounds_per_cubic_foot, lb_per_cu_ft,
58 compound_unit<mass::pounds, inverse<volume::cubic_foot>>)
60 compound_unit<mass::pounds, inverse<volume::cubic_inch>>)
61UNIT_ADD(density, pounds_per_gallon, pounds_per_gallon, lb_per_gal,
62 compound_unit<mass::pounds, inverse<volume::gallon>>)
64 compound_unit<mass::slugs, inverse<volume::cubic_foot>>)
65
67#endif
68
69using namespace density;
70} // namespace units
#define UNIT_ADD_CATEGORY_TRAIT(unitCategory)
Macro to create the is_category_unit type trait.
Definition: base.h:369
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition: base.h:1134
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1434
Definition: array.h:89
Unit Conversion Library namespace.
Definition: data.h:31
compound_unit< mass::grams, inverse< volume::milliliter > > oz_per_cu_ft
Definition: density.h:51
squared< angle::degrees > UNIT_ADD(solid_angle, spat, spats, sp, unit< std::ratio< 4 >, steradians, std::ratio< 1 > >) using namespace solid_angle
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > compound_unit< mass::ounces, inverse< volume::gallon > > lb_per_cu_in
Definition: density.h:59
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > compound_unit< mass::ounces, inverse< volume::gallon > > compound_unit< mass::pounds, inverse< volume::cubic_inch > > slug_per_cu_ft
Definition: density.h:63
compound_unit< mass::grams, inverse< volume::milliliter > > ounces_per_cubic_foot
Definition: density.h:51
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > compound_unit< mass::ounces, inverse< volume::gallon > > compound_unit< mass::pounds, inverse< volume::cubic_inch > > slugs_per_cubic_foot
Definition: density.h:63
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > oz_per_gal
Definition: density.h:55
grams_per_milliliter
Definition: density.h:46
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > compound_unit< mass::ounces, inverse< volume::gallon > > pounds_per_cubic_inch
Definition: density.h:59
pounds
Definition: mass.h:44
compound_unit< mass::grams, inverse< volume::milliliter > > compound_unit< mass::ounces, inverse< volume::cubic_foot > > ounces_per_gallon
Definition: density.h:55
g_per_mL
Definition: density.h:46
Class representing SI base unit types.
Definition: base.h:757
Type representing an arbitrary unit.
Definition: base.h:884