/** * Clones the derived unit changing the identifiers. * * @param id * The identifiers for the new unit. * @return The new unit. */ public final Unit clone(final UnitName id) { return new DerivedUnitImpl(dimension, id); }
/** * Constructs a dimensionless derived unit from nothing. */ protected DerivedUnitImpl() { // dimensionless derived unit this(new UnitDimension(), dimensionlessID()); }
/** * Indicates if values in this unit are convertible with another unit. * * @param that * The other unit. * @return <code>true</code> if and only if values in this unit are * convertible to values in <code> * that</code>. */ @Override public final boolean isCompatible(final Unit that) { final DerivedUnit unit = that.getDerivedUnit(); return equals(unit) || isReciprocalOf(unit); }
System.out.println("secondPerMeter = \"" + secondPerMeter + '"'); System.out.println("meterPerSecond.isReciprocalOf(secondPerMeter)=" + meterPerSecond.isReciprocalOf(secondPerMeter)); System.out.println("meter.toDerivedUnit(1.0)=" + meter.toDerivedUnit(1.0)); System.out .println("sPerS.isDimensionless()=" + sPerS.isDimensionless()); meterPerSecond.raiseTo(2); meter.myDivideBy(meterPerSecond);
/** * Converts numerical values to this unit from the derived unit. Obviously, * the numerical values are unchanged. * * @param input * The numerical values in the derived unit. * @param output * The numerical values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. */ public final float[] fromDerivedUnit(final float[] input, final float[] output) { return toDerivedUnit(input, output); }
/** * Returns the quantity dimension of this derived unit. * * @return The quantity dimension of this derived unit. */ public final QuantityDimension getQuantityDimension() { return getDimension().getQuantityDimension(); }
/** * Returns the canonical string representation of the unit. * * @return The canonical string representation. */ public String getCanonicalString() { return DerivedUnitImpl.DIMENSIONLESS.equals(_unit) ? Double.toString(getScale()) : Double.toString(getScale()) + " " + _unit.toString(); }
/** * Returns a string representation of this unit. If the symbol or name is * available, then that is returned; otherwise, the corresponding expression * in base units is returned. * * @return The string expression for this derived unit. */ @Override public String toString() { final String string = super.toString(); // get symbol or name return string != null ? string : getCanonicalString(); }
case PERIOD: number = number(); unit = DerivedUnitImpl.DIMENSIONLESS.multiplyBy(number); break; case SYMBOL:
throw new AssertionError(); myAssert(parser, "lg(re: 1)", DerivedUnitImpl.DIMENSIONLESS.log(10)); myAssert(parser, "0.1 lg(re 1 mm)", m.multiplyBy(1e-3).log(10) .multiplyBy(0.1));
System.out.println("secondPerMeter = \"" + secondPerMeter + '"'); System.out.println("meterPerSecond.isReciprocalOf(secondPerMeter)=" + meterPerSecond.isReciprocalOf(secondPerMeter)); System.out.println("meter.toDerivedUnit(1.0)=" + meter.toDerivedUnit(1.0)); System.out .println("sPerS.isDimensionless()=" + sPerS.isDimensionless()); meterPerSecond.raiseTo(2); meter.myDivideBy(meterPerSecond);
/** * Converts numerical values to this unit from the derived unit. Obviously, * the numerical values are unchanged. * * @param input * The numerical values in the derived unit. * @param output * The numerical values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. */ public final double[] fromDerivedUnit(final double[] input, final double[] output) { return toDerivedUnit(input, output); }
/** * Returns the quantity dimension of this derived unit. * * @return The quantity dimension of this derived unit. */ public final QuantityDimension getQuantityDimension() { return getDimension().getQuantityDimension(); }
/** * Returns the canonical string representation of the unit. * * @return The canonical string representation. */ public String getCanonicalString() { return DerivedUnitImpl.DIMENSIONLESS.equals(_unit) ? Double.toString(getScale()) : Double.toString(getScale()) + " " + _unit.toString(); }
/** * Returns a string representation of this unit. If the symbol or name is * available, then that is returned; otherwise, the corresponding expression * in base units is returned. * * @return The string expression for this derived unit. */ @Override public String toString() { final String string = super.toString(); // get symbol or name return string != null ? string : getCanonicalString(); }
case PERIOD: number = number(); unit = DerivedUnitImpl.DIMENSIONLESS.multiplyBy(number); break; case SYMBOL:
throw new AssertionError(); myAssert(parser, "lg(re: 1)", DerivedUnitImpl.DIMENSIONLESS.log(10)); myAssert(parser, "0.1 lg(re 1 mm)", m.multiplyBy(1e-3).log(10) .multiplyBy(0.1));
/** * Clones the derived unit changing the identifiers. * * @param id * The identifiers for the new unit. * @return The new unit. */ public final Unit clone(final UnitName id) { return new DerivedUnitImpl(dimension, id); }
/** * Indicates if values in this unit are convertible with another unit. * * @param that * The other unit. * @return <code>true</code> if and only if values in this unit are * convertible to values in <code> * that</code>. */ @Override public final boolean isCompatible(final Unit that) { final DerivedUnit unit = that.getDerivedUnit(); return equals(unit) || isReciprocalOf(unit); }
/** * Converts numerical values to this unit from the derived unit. Obviously, * the numerical values are unchanged. * * @param input * The numerical values in the derived unit. * @param output * The numerical values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. */ public final float[] fromDerivedUnit(final float[] input, final float[] output) { return toDerivedUnit(input, output); }