-
Notifications
You must be signed in to change notification settings - Fork 401
Closed
Description
Per discussion in #519, we want to construct quantities using a unit system such as SI or a custom unit system. The advantage is consistent base units and not having to specify the unit when constructing quantities.
So you can do
new Length(1); // 1 meter, SI unit system
new Length(1, UnitSystem.SI); // same
new Length(1, myUnitSystem); // whatever length unit you configured in your system
Implementation
- Add constructor
MyQuantity(double numericValue, UnitSystem unitSystem) {}
- Add constructor
MyQuantity(double numericValue) : MyQuantity(numericValue, UnitSystem.SI) {}
Quantities with dimensions matching base units is easy
public Length(double numericValue, UnitSystem unitSystem)
: this(numericValue, unitSystem.BaseUnits.Length) { }
Dimensionless quantities?
Information
, Ratio
, Angle
, etc...
public Information(decimal numericValue, UnitSystem unitSystem)
: this(numericValue, unitSystem.BaseUnits./*???*/) { }
These are not coupled to any unit system, so we can keep the existing choice of base unit?
Logarithmic quantities?
Level
(dB), PoweRatio
, AmplitudeRatio
public PowerRatio(decimal numericValue, UnitSystem unitSystem)
: this(numericValue, unitSystem.BaseUnits./*???*/) { }
Unit system: (used in any unit system)
Unit system: (not in a named unit system)
They seem uncoupled from unit systems, so we can keep the existing choices of base unit?
Non-trivial quantities?
Most quantities fall in this category. How do we construct them given a non-SI instance of UnitSystem
?
Unit system: Système International d'Unités (SI)
public ElectricChargeDensity(decimal numericValue, UnitSystem unitSystem)
: this(numericValue, unitSystem.BaseUnits./*???*/) { }
Metadata
Metadata
Assignees
Labels
No labels