You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following my comments on the subject in #1200 here is the proposed modification to the IQuantity interfaces:
ILinearQuantity - in v6 Release #1200 I used the name IVectorQuantity but after some reflection I decided that the word Linear is a better fit (in fact, if we look at the conversion expressions- they are all of the form ax, without an offset)
/// <summary>/// Represents a quantity that has both magnitude and direction, supporting various arithmetic operations and/// comparisons./// </summary>/// <remarks>/// This interface defines standard linear arithmetic operations such as addition, subtraction, multiplication, and/// division./// These types of quantities naturally support comparison operations with either absolute or relative tolerance, which/// is useful for determining equality within a certain margin of error./// <para>/// For more information, see the Wikipedia page on/// <a href="https://en.wikipedia.org/wiki/Dimensional_analysis#Geometry:_position_vs._displacement">/// Dimensional/// Analysis/// </a>/// ./// </para>/// </remarks>/// <typeparam name="TSelf">The type that implements this interface.</typeparam>publicinterfaceILinearQuantity<TSelf>:IQuantityInstance<TSelf>
#if NET7_0_OR_GREATER
,IAdditiveIdentity<TSelf,TSelf>
#endif
whereTSelf:ILinearQuantity<TSelf>{
#if NET7_0_OR_GREATER/// <summary>/// The zero value of this quantity./// </summary>staticabstractTSelfZero{get;}staticTSelfIAdditiveIdentity<TSelf,TSelf>.AdditiveIdentity{get=>TSelf.Zero;}
#endif
#if EXTENDED_EQUALS_INTERFACE/// <summary>/// <para>/// Compare equality to <paramref name="other"/> given a <paramref name="tolerance"/> for the maximum allowed +/- difference./// </para>/// <example>/// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm)./// <code>/// var a = Length.FromMeters(2.0);/// var b = Length.FromMeters(2.1);/// var tolerance = Length.FromCentimeters(10);/// a.Equals(b, tolerance); // true, 2m equals 2.1m +/- 0.1m/// </code>/// </example>/// <para>/// It is generally advised against specifying "zero" tolerance, due to the nature of floating-point operations./// </para>/// </summary>/// <param name="other">The other quantity to compare to.</param>/// <param name="tolerance">The absolute tolerance value. Must be greater than or equal to zero.</param>/// <returns>True if the absolute difference between the two values is not greater than the specified tolerance.</returns>boolEquals(TSelf?other,TSelftolerance);
#endif
}/// <summary>/// An <see cref="IQuantity{TSelf, TUnitType}" /> that (in .NET 7+) implements generic math interfaces for arithmetic/// operations./// </summary>/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>publicinterfaceIArithmeticQuantity<TSelf,TUnitType>:IQuantity<TSelf,TUnitType>,ILinearQuantity<TSelf>
#if NET7_0_OR_GREATER
,IAdditionOperators<TSelf,TSelf,TSelf>,ISubtractionOperators<TSelf,TSelf,TSelf>,IMultiplyOperators<TSelf,QuantityValue,TSelf>,IDivisionOperators<TSelf,QuantityValue,TSelf>,IUnaryNegationOperators<TSelf,TSelf>
#endif
whereTSelf:IArithmeticQuantity<TSelf,TUnitType>whereTUnitType:struct,Enum{}
ILogarithmicQuantity - in NET7_OR_GREATER I introduce the static LogarithmicScalingFactor, however in netstandard this needs to either be an instance member ( 😞 ) or alternatively I could introduce an extra interface for it's QuantityInfo, overriding the property to something of the sort new ILogarithmicQuantityInfo<TQuantity> QuantityInfo { get; }
/// <summary>/// Represents a logarithmic quantity that supports arithmetic operations and implements generic math interfaces /// (in .NET 7+). This interface is designed for quantities that are logarithmic in nature, such as decibels./// </summary>/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>/// <remarks>/// Logarithmic quantities are different from linear quantities in that they represent values on a logarithmic scale./// This interface extends <see cref="IQuantity{TSelf, TUnitType}" /> and provides additional functionality specific /// to logarithmic quantities, including arithmetic operations and a logarithmic scaling factor./// The logarithmic scale assumed here is base-10./// </remarks>publicinterfaceILogarithmicQuantity<TSelf>:IQuantityInstance<TSelf>
#if NET7_0_OR_GREATER
,IMultiplicativeIdentity<TSelf,TSelf>
#endif
whereTSelf:ILogarithmicQuantity<TSelf>{
#if NET7_0_OR_GREATER/// <summary>/// Gets the logarithmic scaling factor used to convert between linear and logarithmic units./// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20./// </summary>/// <value>/// The logarithmic scaling factor./// </value>staticabstractQuantityValueLogarithmicScalingFactor{get;}/// <summary>/// The zero value of this quantity./// </summary>staticabstractTSelfZero{get;}staticTSelfIMultiplicativeIdentity<TSelf,TSelf>.MultiplicativeIdentity=>TSelf.Zero;
#else
/// <summary>/// Gets the logarithmic scaling factor used to convert between linear and logarithmic units./// This factor is typically 10, but there are exceptions such as the PowerRatio, which uses 20./// </summary>/// <value>/// The logarithmic scaling factor./// </value>QuantityValueLogarithmicScalingFactor{get;}
#endif
}/// <inheritdoc cref="ILogarithmicQuantity{TSelf}"/>/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>publicinterfaceILogarithmicQuantity<TSelf,TUnitType>:IQuantity<TSelf,TUnitType>,ILogarithmicQuantity<TSelf>
#if NET7_0_OR_GREATER
,IAdditionOperators<TSelf,TSelf,TSelf>,ISubtractionOperators<TSelf,TSelf,TSelf>,IMultiplyOperators<TSelf,QuantityValue,TSelf>,IDivisionOperators<TSelf,QuantityValue,TSelf>,IUnaryNegationOperators<TSelf,TSelf>
#endif
whereTSelf:ILogarithmicQuantity<TSelf,TUnitType>whereTUnitType:struct,Enum{}
IAffineQuantity: there is only one of these- the Temperature with it's TOffset being the TemperatureDelta (also note that the conversion functions here are of the form ax + b)
/// <summary>/// An <see cref="IQuantity{TSelf}"/> that (in .NET 7+) implements generic math interfaces for arithmetic operations./// </summary>/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>/// <typeparam name="TOffset"></typeparam>publicinterfaceIAffineQuantity<TSelf,TOffset>:IQuantityInstance<TSelf>
#if NET7_0_OR_GREATER
,IAdditiveIdentity<TSelf,TOffset>whereTOffset:IAdditiveIdentity<TOffset,TOffset>
#endif
whereTSelf:IAffineQuantity<TSelf,TOffset>{
#if NET7_0_OR_GREATER/// <summary>/// The zero value of this quantity./// </summary>staticabstractTSelfZero{get;}staticTOffsetIAdditiveIdentity<TSelf,TOffset>.AdditiveIdentity=>TOffset.AdditiveIdentity;
#endif
#if EXTENDED_EQUALS_INTERFACE/// <summary>/// <para>/// Compare equality to <paramref name="other"/> given a <paramref name="tolerance"/> for the maximum allowed +/- difference./// </para>/// <example>/// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm)./// <code>/// var a = Length.FromMeters(2.0);/// var b = Length.FromMeters(2.1);/// var tolerance = Length.FromCentimeters(10);/// a.Equals(b, tolerance); // true, 2m equals 2.1m +/- 0.1m/// </code>/// </example>/// <para>/// It is generally advised against specifying "zero" tolerance, due to the nature of floating-point operations./// </para>/// </summary>/// <param name="other">The other quantity to compare to.</param>/// <param name="tolerance">The absolute tolerance value. Must be greater than or equal to zero.</param>/// <returns>True if the absolute difference between the two values is not greater than the specified tolerance.</returns>boolEquals(TSelf?other,TOffsettolerance);
#endif
}/// <summary>/// An <see cref="IQuantity{TSelf, TUnitType}"/> that (in .NET 7+) implements generic math interfaces for arithmetic operations./// </summary>/// <typeparam name="TSelf">The type itself, for the CRT pattern.</typeparam>/// <typeparam name="TUnitType">The underlying unit enum type.</typeparam>/// <typeparam name="TOffset"></typeparam>publicinterfaceIAffineQuantity<TSelf,TUnitType,TOffset>:IQuantity<TSelf,TUnitType>,IAffineQuantity<TSelf,TOffset>
#if NET7_0_OR_GREATER
,IAdditionOperators<TSelf,TOffset,TSelf>,ISubtractionOperators<TSelf,TSelf,TOffset>whereTOffset:IAdditiveIdentity<TOffset,TOffset>
#endif
whereTSelf:IAffineQuantity<TSelf,TUnitType,TOffset>whereTUnitType:struct,Enum{}
Following my comments on the subject in #1200 here is the proposed modification to the
IQuantityinterfaces:ILinearQuantity- in v6 Release #1200 I used the nameIVectorQuantitybut after some reflection I decided that the wordLinearis a better fit (in fact, if we look at the conversion expressions- they are all of the formax, without an offset)NET7_OR_GREATERI introduce the staticLogarithmicScalingFactor, however innetstandardthis needs to either be an instance member ( 😞 ) or alternatively I could introduce an extra interface for it'sQuantityInfo, overriding the property to something of the sortnew ILogarithmicQuantityInfo<TQuantity> QuantityInfo { get; }IAffineQuantity: there is only one of these- theTemperaturewith it'sTOffsetbeing theTemperatureDelta(also note that the conversion functions here are of the formax + b)