-
Notifications
You must be signed in to change notification settings - Fork 1
/
units.hpp
67 lines (56 loc) · 2.15 KB
/
units.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** @file Define constants for some physical units.
*
* Use these constants throughout your code whenever you encounter physical
* quantities. When doing conversions the word "in" can be translated into
* arithmetic as "divided by". For example
* @code
* auto lengthInInch = length / cu::inch;
* @endcode
*
* Currently, all basic SI units have the value 1. However, a program should
* not rely on this and produce the same results independent of the concrete
* values.
*
* @author Ralph Tandetzky
*/
#pragma once
namespace cu
{
constexpr double pi = 3.14159265358979323846;
constexpr double goldenRatio = 1.61803398874989484820;
constexpr double second = 1.;
constexpr double millisecond = 1.e-3 * second;
constexpr double microsecond = 1.e-6 * second;
constexpr double nanosecond = 1.e-9 * second;
constexpr double minute = 60 * second;
constexpr double hour = 60 * minute;
constexpr double day = 24 * hour;
constexpr double meter = 1.;
constexpr double kilometer = 1.e+3 * meter;
constexpr double decimeter = 1.e-1 * meter;
constexpr double centimeter = 1.e-2 * meter;
constexpr double millimeter = 1.e-3 * meter;
constexpr double micrometer = 1.e-6 * meter;
constexpr double nanometer = 1.e-9 * meter;
constexpr double inch = 2.54 * centimeter;
constexpr double foot = 12 * inch;
constexpr double yard = 3 * foot;
constexpr double Hertz = 1/second;
constexpr double kiloHertz = 1.e3*Hertz;
constexpr double megaHertz = 1.e6*Hertz;
constexpr double gigaHertz = 1.e9*Hertz;
constexpr double Volt = 1.;
constexpr double megaVolt = 1.e+6 * Volt;
constexpr double kiloVolt = 1.e+3 * Volt;
constexpr double milliVolt = 1.e-3 * Volt;
constexpr double microVolt = 1.e-6 * Volt;
constexpr double Ampere = 1.;
constexpr double milliAmpere = 1.e-3 * Ampere;
constexpr double microAmpere = 1.e-6 * Ampere;
constexpr double Coulomb = Ampere * second;
constexpr double milliCoulomb = 1.e-3 * Coulomb;
constexpr double microCoulomb = 1.e-6 * Coulomb;
constexpr double nanoCoulomb = 1.e-9 * Coulomb;
constexpr double picoCoulomb = 1.e-12 * Coulomb;
constexpr double femtoCoulomb = 1.e-15 * Coulomb;
} // namespace cu