Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Dimensionless.cs
1using System;
3
5{
10 {
15 {
16 }
17
21 public string Name => "Dimensionless";
22
26 public AtomicUnit ReferenceUnit => referenceUnit;
27
31 public Unit Reference => reference;
32
33 private static readonly AtomicUnit referenceUnit = new AtomicUnit("1");
34 private static readonly Unit reference = new Unit(referenceUnit);
35
39 public string[] BaseUnits
40 {
41 get
42 {
43 return new string[]
44 {
45 "1",
46 "pcs",
47 "dz",
48 "dozen",
49 "gr",
50 "gross",
51 "%",
52 "‰",
53 "‱",
54 "%0",
55 "%00",
56 "°",
57 "rad",
58 "deg"
59 };
60 }
61 }
62
71 public bool ToReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
72 {
73 double k;
74
75 switch (BaseUnit)
76 {
77 case "1":
78 case "pcs":
79 case "rad":
80 return true;
81
82 case "dz":
83 case "dozen":
84 k = Math.Pow(12, Exponent);
85 break;
86
87 case "gr":
88 case "gross":
89 k = Math.Pow(144, Exponent);
90 break;
91
92 case "%":
93 k = Math.Pow(1e-2, Exponent);
94 break;
95
96 case "‰":
97 case "%0":
98 k = Math.Pow(1e-3, Exponent);
99 break;
100
101 case "‱":
102 case "%00":
103 k = Math.Pow(1e-4, Exponent);
104 break;
105
106 case "°":
107 case "deg":
108 k = Math.Pow(DegToRad.Scale, Exponent);
109 break;
110
111 default:
112 return false;
113 }
114
115 Magnitude *= k;
116 NrDecimals -= Math.Log10(k);
117
118 return true;
119 }
120
129 public bool FromReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
130 {
131 return this.ToReferenceUnit(ref Magnitude, ref NrDecimals, BaseUnit, -Exponent);
132 }
133
134 }
135}
Degrees to radians operator.
Definition: DegToRad.cs:13
Represents an atomic unit.
Definition: AtomicUnit.cs:7
bool ToReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
Tries to convert a magnitude from a specified base unit, to the reference unit.
AtomicUnit ReferenceUnit
Reference unit of category.
string[] BaseUnits
Base Units supported.
bool FromReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
Tries to convert a magnitude to a specified base unit, from the reference unit.
Unit Reference
Reference unit for category.
Represents a unit.
Definition: Unit.cs:16
Interface for physical base quantities
Definition: IBaseQuantity.cs:7