public UnitPoint2D(SIPrefix prefix, IUnitDefinition unit, double x, double y) : base( prefix.GetMultiplier() * unit.ConvertToUnitValue(x).Value, prefix.GetMultiplier() * unit.ConvertToUnitValue(y).Value) { Unit = unit.CorrespondingCompoundUnit; }
public UnitDefinition( string stringRepresentation, bool isSIUnit, CompoundUnit correspondingCompoundUnit, Func <double, double> toUnitValue, Func <double, double> convertBack, IList <string> alternativeStringRepresentations = null) { this.toUnitValue = toUnitValue; this.convertBack = convertBack; StringRepresentation = stringRepresentation; IsSIUnit = isSIUnit; CorrespondingCompoundUnit = correspondingCompoundUnit; AlternativeStringRepresentations = alternativeStringRepresentations ?? new List <string>(); }
private static UnitValue CombineUnitConversions( IEnumerable <UnitValue> nomniatorUnitConversions, IEnumerable <UnitValue> denomniatorUnitConversions) { var combinedMultiplier10Base = 0d; var combinedUnit = new CompoundUnit(); foreach (var nomniatorUnitConversion in nomniatorUnitConversions) { combinedUnit *= nomniatorUnitConversion.Unit; combinedMultiplier10Base += Math.Log10(nomniatorUnitConversion.Value); } foreach (var denomniatorUnitConversion in denomniatorUnitConversions) { combinedUnit /= denomniatorUnitConversion.Unit; combinedMultiplier10Base -= Math.Log10(denomniatorUnitConversion.Value); } var combinedMultiplier = Math.Pow(10, combinedMultiplier10Base); return(new UnitValue(combinedUnit, combinedMultiplier)); }
public UnitPoint2D(CompoundUnit unit, double x, double y) : base(x, y) { Unit = unit; }
public UnitPoint2D(UnitValue x, UnitValue y) : base(x.In(x.Unit), y.In(x.Unit)) { Unit = x.Unit; }
public static bool CanConvertTo(this UnitValue unitValue, CompoundUnit unit) { return(unitValue.Unit == unit); }
public UnitVector2D(CompoundUnit unit, double x, double y) : base(x, y) { Unit = unit; }
public UnitVector2D(UnitValue x, UnitValue y) : base(x.In(x.Unit), y.In(x.Unit)) { Unit = x.Unit; }
public UnitVector3D(CompoundUnit unit, double x, double y, double z) : base(x, y, z) { Unit = unit; }
public UnitVector3D(UnitValue x, UnitValue y, UnitValue z) : base(x.In(x.Unit), y.In(x.Unit), z.In(x.Unit)) { Unit = x.Unit; }
public UnitValue(CompoundUnit unit, double value) { Unit = unit; Value = value; }
public UnitPoint3D(CompoundUnit unit, double x, double y, double z) : base(x, y, z) { Unit = unit; }