diff --git a/NEOSPlus/Quantity/Capacitance.cs b/NEOSPlus/Quantity/Capacitance.cs new file mode 100644 index 0000000..8991c96 --- /dev/null +++ b/NEOSPlus/Quantity/Capacitance.cs @@ -0,0 +1,145 @@ +using System; +using QuantityX; + +namespace NEOSPlus.Quantity +{ + public readonly struct Capacitance : IQuantitySI, IQuantitySI, IQuantity, IQuantity, IComparable, IEquatable + { + public readonly double BaseValue; + + public static readonly Unit Farad = new UnitSI(0, "F", "farad"); + + double IQuantity.BaseValue => BaseValue; + + public double SIPower => 1.0; + + public Unit DefaultUnit => Farad; + + public Capacitance(double baseValue = 0.0) + { + this = default(Capacitance); + BaseValue = baseValue; + } + + public bool Equals(Capacitance other) + { + return BaseValue == other.BaseValue; + } + + public int CompareTo(Capacitance other) + { + return BaseValue.CompareTo(other.BaseValue); + } + + public string[] GetShortBaseNames() + { + return new string[] { "F" }; + } + + public string[] GetLongBaseNames() + { + return new string[] { "farads", "farad" }; + } + + public IUnit[] GetCommonSIUnits() + { + return new IUnit[] + { + SI.Pico, + SI.Nano, + SI.Micro, + SI.Milli, + Farad, + SI.Kilo, + SI.Mega, + SI.Giga + }; + } + + public IUnit[] GetExludedSIUnits() + { + return new IUnit[] + { + SI.Yotta, + SI.Zetta, + SI.Exa, + SI.Peta, + SI.Tera, + SI.Deca, + SI.Hecto, + SI.Centi, + SI.Deci, + SI.Yocto, + SI.Zepto, + SI.Atto, + SI.Femto + }; + } + + public Capacitance New(double baseVal) + { + return new Capacitance(baseVal); + } + + public Capacitance Add(Capacitance q) + { + return new Capacitance(BaseValue + q.BaseValue); + } + + public Capacitance Subtract(Capacitance q) + { + return new Capacitance(BaseValue - q.BaseValue); + } + + public Capacitance Multiply(double n) + { + return new Capacitance(BaseValue * n); + } + + public Capacitance Divide(double n) + { + return new Capacitance(BaseValue / n); + } + + public Ratio Divide(Capacitance q) + { + return new Ratio(BaseValue / q.BaseValue); + } + + public static Capacitance operator +(Capacitance a, Capacitance b) + { + return a.Add(b); + } + + public static Capacitance operator -(Capacitance a, Capacitance b) + { + return a.Subtract(b); + } + + public static Capacitance operator *(Capacitance a, double n) + { + return a.Multiply(n); + } + + public static Capacitance operator /(Capacitance a, double n) + { + return a.Divide(n); + } + + public static Ratio operator /(Capacitance a, Capacitance b) + { + return a.Divide(b); + } + + public static Capacitance operator -(Capacitance a) + { + return a.Multiply(-1.0); + } + + public override string ToString() + { + return this.FormatAuto(); + } + } +} + diff --git a/NEOSPlus/Quantity/Joules.cs b/NEOSPlus/Quantity/Joules.cs new file mode 100644 index 0000000..5b1dc56 --- /dev/null +++ b/NEOSPlus/Quantity/Joules.cs @@ -0,0 +1,145 @@ +using System; +using QuantityX; + +namespace NEOSPlus.Quantity +{ + public readonly struct Joule : IQuantitySI, IQuantitySI, IQuantity, IQuantity, IComparable, IEquatable + { + public readonly double BaseValue; + + public static readonly Unit Joules = new UnitSI(0, "J", "joule"); + + double IQuantity.BaseValue => BaseValue; + + public double SIPower => 1.0; + + public Unit DefaultUnit => Joules; + + public Joule(double baseValue = 0.0) + { + this = default(Joule); + BaseValue = baseValue; + } + + public bool Equals(Joule other) + { + return BaseValue == other.BaseValue; + } + + public int CompareTo(Joule other) + { + return BaseValue.CompareTo(other.BaseValue); + } + + public string[] GetShortBaseNames() + { + return new string[] { "J" }; + } + + public string[] GetLongBaseNames() + { + return new string[] { "joules", "joule" }; + } + + public IUnit[] GetCommonSIUnits() + { + return new IUnit[] + { + SI.Pico, + SI.Nano, + SI.Micro, + SI.Milli, + Joules, + SI.Kilo, + SI.Mega, + SI.Giga, + SI.Tera, + SI.Peta + }; + } + + public IUnit[] GetExludedSIUnits() + { + return new IUnit[] + { + SI.Yotta, + SI.Zetta, + SI.Exa, + SI.Deca, + SI.Hecto, + SI.Centi, + SI.Deci, + SI.Yocto, + SI.Zepto, + SI.Atto, + SI.Femto + }; + } + + public Joule New(double baseVal) + { + return new Joule(baseVal); + } + + public Joule Add(Joule q) + { + return new Joule(BaseValue + q.BaseValue); + } + + public Joule Subtract(Joule q) + { + return new Joule(BaseValue - q.BaseValue); + } + + public Joule Multiply(double n) + { + return new Joule(BaseValue * n); + } + + public Joule Divide(double n) + { + return new Joule(BaseValue / n); + } + + public Ratio Divide(Joule q) + { + return new Ratio(BaseValue / q.BaseValue); + } + + public static Joule operator +(Joule a, Joule b) + { + return a.Add(b); + } + + public static Joule operator -(Joule a, Joule b) + { + return a.Subtract(b); + } + + public static Joule operator *(Joule a, double n) + { + return a.Multiply(n); + } + + public static Joule operator /(Joule a, double n) + { + return a.Divide(n); + } + + public static Ratio operator /(Joule a, Joule b) + { + return a.Divide(b); + } + + public static Joule operator -(Joule a) + { + return a.Multiply(-1.0); + } + + public override string ToString() + { + return this.FormatAuto(); + } + } +} +