Search in sources :

Example 1 with Dimension

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);
}
Also used : Dimension(javax.measure.Dimension) Test(org.junit.Test)

Example 2 with Dimension

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());
}
Also used : Dimension(javax.measure.Dimension) QuantityDimension(tech.units.indriya.quantity.QuantityDimension) Test(org.junit.jupiter.api.Test)

Example 3 with Dimension

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;
}
Also used : Dimension(javax.measure.Dimension) QuantityDimension(tech.units.indriya.quantity.QuantityDimension) Map(java.util.Map)

Example 4 with Dimension

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;
}
Also used : Dimension(javax.measure.Dimension) QuantityDimension(tech.units.indriya.quantity.QuantityDimension)

Example 5 with 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;
}
Also used : Dimension(javax.measure.Dimension) QuantityDimension(tec.uom.se.quantity.QuantityDimension) Map(java.util.Map)

Aggregations

Dimension (javax.measure.Dimension)18 Test (org.junit.Test)7 Map (java.util.Map)3 QuantityDimension (tech.units.indriya.quantity.QuantityDimension)3 HashMap (java.util.HashMap)2 UnitConverter (javax.measure.UnitConverter)2 Fraction (org.apache.sis.math.Fraction)2 QuantityDimension (tec.uom.se.quantity.QuantityDimension)2 AccessElement (gov.sandia.n2a.language.AccessElement)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Unit (javax.measure.Unit)1 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)1 UnsupportedImplementationException (org.apache.sis.util.UnsupportedImplementationException)1 Test (org.junit.jupiter.api.Test)1 Element (org.w3c.dom.Element)1