public IDimension GetOrAddRHSDimensionFor(IDimension dimension) { var dimensionName = rhsDimensionName(dimension); if (Has(dimensionName)) { return(Dimension(dimensionName)); } var unitName = rhsDefaultUnitName(dimension); // RHS is per Time hence -1 var rhsDimensionRepresentation = new BaseDimensionRepresentation(dimension.BaseRepresentation); rhsDimensionRepresentation.TimeExponent -= 1; var rhsDimension = new Dimension(rhsDimensionRepresentation, dimensionName, unitName); var equivalentRHSDimension = findFirstEquivalentDimension(rhsDimension, unitName); if (equivalentRHSDimension != null) { return(equivalentRHSDimension); } // Equivalent dimensions does noo exist. We add it and return it AddDimension(rhsDimension); return(rhsDimension); }
public Dimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName) : this() { _baseRepresentation = baseRepresentation; Name = dimensionName; BaseUnit = new Unit(baseUnitName, 1.0, 0.0); _units.Add(BaseUnit); }
public Dimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName) { BaseRepresentation = baseRepresentation; Name = dimensionName; BaseUnit = new Unit(baseUnitName, 1f, 0f); _units.Add(BaseUnit); }
public BaseDimensionRepresentation(BaseDimensionRepresentation baseDimensionRepresentation) { LengthExponent = baseDimensionRepresentation.LengthExponent; MassExponent = baseDimensionRepresentation.MassExponent; TimeExponent = baseDimensionRepresentation.TimeExponent; ElectricCurrentExponent = baseDimensionRepresentation.ElectricCurrentExponent; TemperatureExponent = baseDimensionRepresentation.TemperatureExponent; AmountExponent = baseDimensionRepresentation.AmountExponent; LuminousIntensityExponent = baseDimensionRepresentation.LuminousIntensityExponent; }
public BaseDimensionRepresentation DividedBy(BaseDimensionRepresentation other) { var exponents = new double[BASE_DIMENSIONS]; foreach (var baseDimension in Enum.GetValues(typeof(BaseDimension))) { var i = (int)baseDimension; exponents[i] = _exponents[i] - other._exponents[i]; } return(new BaseDimensionRepresentation(exponents)); }
public IDimension AddDimension(BaseDimensionRepresentation baseRepresentation, string dimensionName, string baseUnitName) { if (Has(dimensionName)) { throw new NotUniqueIdException(dimensionName); } var dimension = new Dimension(baseRepresentation, dimensionName, baseUnitName); _dimensions.Add(dimension.Name, dimension); return(dimension); }
protected bool Equals(BaseDimensionRepresentation other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(EnumHelper.AllValuesFor <BaseDimension>().All(x => Exponent(x) == other.Exponent(x))); }