WPILibC++ 2024.1.1-beta-4
constants.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/area.h"
30#include "units/capacitance.h"
31#include "units/charge.h"
32#include "units/current.h"
33#include "units/dimensionless.h"
34#include "units/energy.h"
35#include "units/force.h"
36#include "units/impedance.h"
37#include "units/length.h"
39#include "units/mass.h"
40#include "units/power.h"
41#include "units/substance.h"
42#include "units/temperature.h"
43#include "units/time.h"
44#include "units/velocity.h"
45
47/**
48 * @name Unit Containers
49 * @anchor constantContainers
50 * @{
51 */
53
54static constexpr const unit_t<PI> pi(
55 1); ///< Ratio of a circle's circumference to its diameter.
56static constexpr const velocity::meters_per_second_t c(
57 299792458.0); ///< Speed of light in vacuum.
58static constexpr const unit_t<
61 G(6.67408e-11); ///< Newtonian constant of gravitation.
63 6.626070040e-34); ///< Planck constant.
64static constexpr const unit_t<
66 mu0(pi * 4.0e-7 * force::newton_t(1) /
67 units::math::cpow<2>(current::ampere_t(1))); ///< vacuum permeability.
68static constexpr const unit_t<
70 epsilon0(1.0 / (mu0 * math::cpow<2>(c))); ///< vacuum permitivity.
71static constexpr const impedance::ohm_t Z0(
72 mu0* c); ///< characteristic impedance of vacuum.
73static constexpr const unit_t<compound_unit<force::newtons, area::square_meter,
75 k_e(1.0 / (4 * pi * epsilon0)); ///< Coulomb's constant.
76static constexpr const charge::coulomb_t e(
77 1.6021766208e-19); ///< elementary charge.
78static constexpr const mass::kilogram_t m_e(
79 9.10938356e-31); ///< electron mass.
80static constexpr const mass::kilogram_t m_p(1.672621898e-27); ///< proton mass.
81static constexpr const unit_t<
83mu_B(e* h / (4 * pi * m_e)); ///< Bohr magneton.
84static constexpr const unit_t<inverse<substance::mol>> N_A(
85 6.022140857e23); ///< Avagadro's Number.
86static constexpr const unit_t<compound_unit<
88 R(8.3144598); ///< Gas constant.
89static constexpr const unit_t<
91 k_B(R / N_A); ///< Boltzmann constant.
92static constexpr const unit_t<
94F(N_A* e); ///< Faraday constant.
95static constexpr const unit_t<
98 sigma((2 * math::cpow<5>(pi) * math::cpow<4>(R)) /
99 (15 * math::cpow<3>(h) * math::cpow<2>(c) *
100 math::cpow<4>(N_A))); ///< Stefan-Boltzmann constant.
101/** @} */
102} // namespace units::constants
Container for values which represent quantities of a given unit.
Definition: base.h:1938
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition: base.h:1146
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition: base.h:1446
Definition: constants.h:46
static constexpr const unit_t< compound_unit< cubed< length::meters >, inverse< mass::kilogram >, inverse< squared< time::seconds > > > > G(6.67408e-11)
Newtonian constant of gravitation.
static constexpr const unit_t< compound_unit< capacitance::farad, inverse< length::meter > > > epsilon0(1.0/(mu0 *math::cpow< 2 >(c)))
vacuum permitivity.
static constexpr const mass::kilogram_t m_e(9.10938356e-31)
electron mass.
static constexpr const unit_t< compound_unit< energy::joules, inverse< temperature::kelvin > > > k_B(R/N_A)
Boltzmann constant.
static constexpr const unit_t< compound_unit< power::watts, inverse< area::square_meters >, inverse< squared< squared< temperature::kelvin > > > > > sigma((2 *math::cpow< 5 >(pi) *math::cpow< 4 >(R))/(15 *math::cpow< 3 >(h) *math::cpow< 2 >(c) *math::cpow< 4 >(N_A)))
Stefan-Boltzmann constant.
static constexpr const unit_t< compound_unit< energy::joules, inverse< temperature::kelvin >, inverse< substance::moles > > > R(8.3144598)
Gas constant.
static constexpr const unit_t< inverse< substance::mol > > N_A(6.022140857e23)
Avagadro's Number.
static constexpr const unit_t< compound_unit< force::newtons, area::square_meter, inverse< squared< charge::coulomb > > > > k_e(1.0/(4 *pi *epsilon0))
Coulomb's constant.
static constexpr const unit_t< compound_unit< force::newtons, inverse< squared< current::ampere > > > > mu0(pi *4.0e-7 *force::newton_t(1)/units::math::cpow< 2 >(current::ampere_t(1)))
vacuum permeability.
static constexpr const unit_t< compound_unit< energy::joules, inverse< magnetic_field_strength::tesla > > > mu_B(e *h/(4 *pi *m_e))
Bohr magneton.
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
static constexpr const unit_t< compound_unit< charge::coulomb, inverse< substance::mol > > > F(N_A *e)
Faraday constant.
static constexpr const unit_t< PI > pi(1)
Ratio of a circle's circumference to its diameter.
static constexpr const impedance::ohm_t Z0(mu0 *c)
characteristic impedance of vacuum.
static constexpr const mass::kilogram_t m_p(1.672621898e-27)
proton mass.
static constexpr const charge::coulomb_t e(1.6021766208e-19)
elementary charge.
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
unit< std::ratio< 1 >, units::category::scalar_unit > scalar
Definition: base.h:2522
Type representing an arbitrary unit.
Definition: base.h:896