From 660a87689c574c1a9c14f7f490f45a12d1764f03 Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 6 Sep 2023 10:16:54 +0100 Subject: [PATCH 1/4] Create Capacitance.cs --- NEOSPlus/Quantity/Capacitance.cs | 1 + 1 file changed, 1 insertion(+) create mode 100644 NEOSPlus/Quantity/Capacitance.cs diff --git a/NEOSPlus/Quantity/Capacitance.cs b/NEOSPlus/Quantity/Capacitance.cs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/NEOSPlus/Quantity/Capacitance.cs @@ -0,0 +1 @@ + From 7d8e8f00811e33c97d45fbdd96bfa3b405dfad34 Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 6 Sep 2023 10:17:46 +0100 Subject: [PATCH 2/4] Update Capacitance.cs --- NEOSPlus/Quantity/Capacitance.cs | 144 +++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/NEOSPlus/Quantity/Capacitance.cs b/NEOSPlus/Quantity/Capacitance.cs index 8b13789..8991c96 100644 --- a/NEOSPlus/Quantity/Capacitance.cs +++ b/NEOSPlus/Quantity/Capacitance.cs @@ -1 +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(); + } + } +} From a2efab681327acb502d25c19c0e7278e8b82dda1 Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 6 Sep 2023 10:57:05 +0100 Subject: [PATCH 3/4] Create Joules.cs --- NEOSPlus/Quantity/Joules.cs | 1 + 1 file changed, 1 insertion(+) create mode 100644 NEOSPlus/Quantity/Joules.cs diff --git a/NEOSPlus/Quantity/Joules.cs b/NEOSPlus/Quantity/Joules.cs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/NEOSPlus/Quantity/Joules.cs @@ -0,0 +1 @@ + From d6df105c05bdda7b806fc7451e87b8697efda628 Mon Sep 17 00:00:00 2001 From: xLinka Date: Wed, 6 Sep 2023 10:57:54 +0100 Subject: [PATCH 4/4] Update Joules.cs --- NEOSPlus/Quantity/Joules.cs | 144 ++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/NEOSPlus/Quantity/Joules.cs b/NEOSPlus/Quantity/Joules.cs index 8b13789..5b1dc56 100644 --- a/NEOSPlus/Quantity/Joules.cs +++ b/NEOSPlus/Quantity/Joules.cs @@ -1 +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(); + } + } +}