/** * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the * current physics model. * * @param dimension * the dimension for which the fundamental dimension is returned. * @return <code>this</code> or a rational product of fundamental dimension. */ public Dimension getFundamentalDimension(Dimension dimension) { Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions(); if (dimensions == null) return dimension; // Fundamental dimension. // Dimensional Product. Dimension fundamentalProduct = QuantityDimension.NONE; for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) { fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue()); } return fundamentalProduct; }
/** * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the * current physics model. * * @param dimension * the dimension for which the fundamental dimension is returned. * @return <code>this</code> or a rational product of fundamental dimension. */ public Dimension getFundamentalDimension(Dimension dimension) { Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions(); if (dimensions == null) return dimension; // Fundamental dimension. // Dimensional Product. Dimension fundamentalProduct = QuantityDimension.NONE; for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) { fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue()); } return fundamentalProduct; }
/** * Returns the fundamental dimension for the one specified. If the specified dimension is a dimensional product, the dimensional product of its * fundamental dimensions is returned. Physical quantities are considered commensurate only if their fundamental dimensions are equals using the * current physics model. * * @param dimension * the dimension for which the fundamental dimension is returned. * @return <code>this</code> or a rational product of fundamental dimension. */ public Dimension getFundamentalDimension(Dimension dimension) { Map<? extends Dimension, Integer> dimensions = dimension.getBaseDimensions(); if (dimensions == null) return dimension; // Fundamental dimension. // Dimensional Product. Dimension fundamentalProduct = QuantityDimension.NONE; for (Map.Entry<? extends Dimension, Integer> e : dimensions.entrySet()) { fundamentalProduct = fundamentalProduct.multiply(this.getFundamentalDimension(e.getKey())).pow(e.getValue()); } return fundamentalProduct; }
/** * Tests {@link UnitDimension#multiply(Dimension)}. */ @Test @DependsOnMethod("testEqualsAndHashCode") public void testMultiply() { assertSame(LENGTH, LENGTH.multiply(DIMENSIONLESS)); assertSame(AREA, LENGTH.multiply(LENGTH)); assertSame(VOLUME, LENGTH.multiply(AREA)); assertSame(VOLUME, AREA .multiply(LENGTH)); final Map<Dimension,Integer> expected = new HashMap<>(4); assertNull(expected.put(LENGTH, 1)); assertNull(expected.put(TIME, 1)); assertMapEquals(expected, LENGTH.multiply(TIME).getBaseDimensions()); }
@Override public Dimension getDimension() { Dimension dimension = QuantityDimension.NONE; for (int i = 0; i < this.getUnitCount(); i++) { Unit<?> unit = this.getUnit(i); if (this.elements != null && unit.getDimension() != null) { Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); dimension = dimension.multiply(d); } } return dimension; }
@Override public Dimension getDimension() { Dimension dimension = QuantityDimension.NONE; for (int i = 0; i < this.getUnitCount(); i++) { Unit<?> unit = this.getUnit(i); if (this.elements != null && unit.getDimension() != null) { Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); dimension = dimension.multiply(d); } } return dimension; }
@Override public Dimension getDimension() { Dimension dimension = QuantityDimension.NONE; for (int i = 0; i < this.getUnitCount(); i++) { Unit<?> unit = this.getUnit(i); if (this.elements != null && unit.getDimension() != null) { Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); if (dimension != null) { dimension = dimension.multiply(d); } else { dimension = d; // XXX hackaround } } } return dimension; }