37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
namespace QWERTYkez.Mensura.Units;
|
|
|
|
/// <summary>
|
|
/// Base value is MetersPerSecondSquared
|
|
/// </summary>
|
|
[UnitGenerator, DebuggerDisplay("m/s2 = {_MetersPerSecondSquared.ToString(\"0.###\")}")]
|
|
public readonly partial record struct Boost
|
|
{
|
|
public static Boost _MeterPerSecondSquared { get; } = new() { _MetersPerSecondSquared = 1 };
|
|
[NotMapped, JsonIgnore] public double _MetersPerSecondSquared { get => _Value; init => _Value = value; }
|
|
|
|
|
|
public static Boost KiloMeterPerSecondSquared { get; } = new() { KiloMetersPerSecondSquared = 1 };
|
|
[NotMapped, JsonIgnore] public double KiloMetersPerSecondSquared
|
|
{
|
|
get => BoostConv.KiloMetersPerSecondSquared.From(_Value);
|
|
init
|
|
{
|
|
_Value = BoostConv.KiloMetersPerSecondSquared.To(value);
|
|
}
|
|
}
|
|
|
|
public static Boost G { get; } = new() { _MetersPerSecondSquared = Constants.g };
|
|
|
|
public Boost AddMetersPerSecondSquared(double value) => new(_Value + value);
|
|
public Boost AddKiloMetersPerSecondSquared(double value) => new(_Value + BoostConv.KiloMetersPerSecondSquared.To(value));
|
|
}
|
|
|
|
internal readonly struct BoostConv
|
|
{
|
|
private BoostConv(double multiplicator) => this.Multiplicator = multiplicator;
|
|
public double To(double value) => value * Multiplicator;
|
|
public double From(double value) => value / Multiplicator;
|
|
public double Multiplicator { get; init; }
|
|
public static BoostConv MetersPerSecondSquared { get; } = new(1);
|
|
public static BoostConv KiloMetersPerSecondSquared { get; } = new(1000);
|
|
} |