use of javax.measure.Dimension in project unit-api by unitsofmeasurement.
the class DimensionTest method testRoot.
@Test
public void testRoot() {
Dimension result = sut.root(2);
assertNotNull(result);
}
use of javax.measure.Dimension in project indriya by unitsofmeasurement.
the class AbsSystemOfUnitsTest method testGetByDim.
@Test
public void testGetByDim() {
Dimension len = QuantityDimension.LENGTH;
Set<? extends Unit<?>> lens = sut.getUnits(len);
assertNotNull(lens);
assertEquals(1, lens.size());
}
use of javax.measure.Dimension in project indriya by unitsofmeasurement.
the class DimensionalModel method getFundamentalDimension.
/**
* 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)
// Fundamental dimension.
return 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;
}
use of javax.measure.Dimension in project indriya by unitsofmeasurement.
the class ProductUnit method getDimension.
@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;
}
use of javax.measure.Dimension in project uom-se by unitsofmeasurement.
the class DimensionalModel method getFundamentalDimension.
/**
* 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)
// Fundamental dimension.
return 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;
}
Aggregations