Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Mass.cs
1using System;
2
4{
8 public class Mass : IBaseQuantity
9 {
13 public Mass()
14 {
15 }
16
20 public string Name => "Mass";
21
25 public AtomicUnit ReferenceUnit => referenceUnit;
26
30 public Unit Reference => reference;
31
32 private static readonly AtomicUnit referenceUnit = new AtomicUnit("g");
33 private static readonly Unit reference = new Unit(referenceUnit);
34
38 public string[] BaseUnits
39 {
40 get
41 {
42 return new string[]
43 {
44 "g",
45 "t",
46 "u",
47 "lb"
48 };
49 }
50 }
51
60 public bool ToReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
61 {
62 double k;
63
64 switch (BaseUnit)
65 {
66 case "g":
67 return true;
68
69 case "t":
70 k = Math.Pow(1e6, Exponent);
71 break;
72
73 case "u":
74 k = Math.Pow(1.66e-24, Exponent);
75 break;
76
77 case "lb":
78 k = Math.Pow(450, Exponent);
79 break;
80
81 default:
82 return false;
83 }
84
85 Magnitude *= k;
86 NrDecimals -= Math.Log10(k);
87
88 return true;
89 }
90
99 public bool FromReferenceUnit(ref double Magnitude, ref double NrDecimals, string BaseUnit, int Exponent)
100 {
101 return this.ToReferenceUnit(ref Magnitude, ref NrDecimals, BaseUnit, -Exponent);
102 }
103
104 }
105}
Represents an atomic unit.
Definition: AtomicUnit.cs:7
It is generally a measure of an object's resistance to changing its state of motion when a force is a...
Definition: Mass.cs:9
string[] BaseUnits
Base Units supported.
Definition: Mass.cs:39
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.
Definition: Mass.cs:99
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.
Definition: Mass.cs:60
Unit Reference
Reference unit of category.
Definition: Mass.cs:30
AtomicUnit ReferenceUnit
Reference unit of base quantity.
Definition: Mass.cs:25
Mass()
It is generally a measure of an object's resistance to changing its state of motion when a force is a...
Definition: Mass.cs:13
string Name
Name of base quantity.
Definition: Mass.cs:20
Represents a unit.
Definition: Unit.cs:15
Interface for physical base quantities
Definition: IBaseQuantity.cs:7