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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
The Gaussian CGS unit system

Note: this system is incomplete. More derived units and constants are coming.





Following, we list all of the [base units](#base-units), [derived units](#derived-units), and
[constants](#constants) that are defined in this unit system.
# Base Units
Constant | Unit | Print Token | Dimensionn
---|---|---|---
SQRTCM | SqrtCentimeter | sqrtcm | 
SQRTG | SqrtGram | sqrtg | 
S | Second | s | Time
# Derived Units
Constant | Unit | Unit Definition | Dimension
---|---|---|---
CM | Centimeter | SqrtCentimeter * SqrtCentimeter | Length
G | Gram | SqrtGram * SqrtGram | Mass
CM2 | Centimeter2 | Centimeter * Centimeter | Area
CM3 | Centimeter3 | Centimeter2 * Centimeter | Volume
S2 | Second2 | Second * Second | 
S3 | Second3 | Second2 * Second | 
S4 | Second4 | Second3 * Second | 
CMPS | CentimeterPerSecond | Centimeter / Second | Velocity
CMPS3 | CentimeterPerSecond3 | Centimeter / Second3 | Jerk
CMPS4 | CentimeterPerSecond4 | Centimeter / Second4 | 
CM2PS | Centimeter2PerSecond | Centimeter2 / Second | 
CM2PS2 | Centimeter2PerSecond2 | Centimeter2 / Second2 | 
CM2PS3 | Centimeter2PerSecond3 | Centimeter2 / Second3 | 
CM3PS | Centimeter3PerSecond | Centimeter3 / Second | 
CM3PS2 | Centimeter3PerSecond2 | Centimeter3 / Second2 | 
CM3PS3 | Centimeter3PerSecond3 | Centimeter3 / Second3 | 
GAL | Gal | Centimeter / Second2 | Acceleration
DYN | Dyne | Gram * Gal | Force
ERG | Erg | Dyne * Centimeter | Energy
ERGPS | ErgPerSecond | Erg / Second | Power
BA | Barye | Dyne / Centimeter2 | Pressure
P | Poise | Gram / Centimeter / Second | 
ST | Stokes | Centimeter2 / Second | 
K | Kayser | Unitless / Centimeter | ReciprocalLength
STATC | StatCoulomb | SqrtGram * SqrtCentimeter * Centimeter / Second | 
STATA | StatAmpere | StatCoulomb / Second | 
STATV | StatVolt | Erg / StatCoulomb | 
# Constants
Name | Constant | Value | Unit | Dimension 
---|---|---|---|---
Meter | M | HECTO * CM | Centimeter | Length
|
*/
pub mod cgs {
    make_units! {
        CGS;
        ONE: Unitless;

        base {
            SQRTCM: SqrtCentimeter, "sqrtcm";
            SQRTG: SqrtGram, "sqrtg";
            S: Second, "s", Time;
        }

        derived {
            CM: Centimeter = (SqrtCentimeter * SqrtCentimeter), Length;
            G: Gram = (SqrtGram * SqrtGram), Mass;
            CM2: Centimeter2 = (Centimeter * Centimeter), Area;
            CM3: Centimeter3 = (Centimeter2 * Centimeter), Volume;
            S2: Second2 = (Second * Second);
            S3: Second3 = (Second2 * Second);
            S4: Second4 = (Second3 * Second);
            CMPS: CentimeterPerSecond = (Centimeter / Second), Velocity;
            CMPS3: CentimeterPerSecond3 = (Centimeter / Second3), Jerk;
            CMPS4: CentimeterPerSecond4 = (Centimeter / Second4);
            CM2PS: Centimeter2PerSecond = (Centimeter2 / Second);
            CM2PS2: Centimeter2PerSecond2 = (Centimeter2 / Second2);
            CM2PS3: Centimeter2PerSecond3 = (Centimeter2 / Second3);
            CM3PS: Centimeter3PerSecond = (Centimeter3 / Second);
            CM3PS2: Centimeter3PerSecond2 = (Centimeter3 / Second2);
            CM3PS3: Centimeter3PerSecond3 = (Centimeter3 / Second3);
            GAL: Gal = (Centimeter / Second2), Acceleration;
            DYN: Dyne = (Gram * Gal), Force;
            ERG: Erg = (Dyne * Centimeter), Energy;
            ERGPS: ErgPerSecond = (Erg / Second), Power;
            BA: Barye = (Dyne / Centimeter2), Pressure;
            P: Poise = (Gram / Centimeter / Second);
            ST: Stokes = (Centimeter2 / Second);
            K: Kayser = (Unitless / Centimeter), ReciprocalLength;
            STATC: StatCoulomb = (SqrtGram * SqrtCentimeter * Centimeter / Second);
            STATA: StatAmpere = (StatCoulomb / Second);
            STATV: StatVolt = (Erg / StatCoulomb);
        }

        constants {
            M: Centimeter = HECTO * CM.value_unsafe;
        }

        fmt = false;
    }

    pub use self::f64consts::*;


    #[test]
    fn test_cgs_constants() {
        #[allow(unused_imports)]
        use f64prefixes::*;
        #[allow(unused_imports)]
        use core::f64::consts;

        assert_eq!(M, HECTO * CM);
    }
}