/** * Converts a value in this unit to the equivalent value in the convertible * derived unit. * * @param amount * The value in this unit. * @return The equivalent value in the convertible derived unit. * @throws ConversionException * Can't convert between units. */ public double toDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(amount + getOffset()); }
/** * Converts a value in the convertible derived unit to the equivalent value * in this unit. * * @param amount * The value in the convertible derived unit. * @return The equivalent value in this unit. * @throws ConversionException * Can't convert between units. */ public double fromDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } return ((DerivableUnit) getUnit()).fromDerivedUnit(amount) - getOffset(); }
/** * Converts a value in this unit to the equivalent value in the convertible * derived unit. * * @param amount * The value in this unit. * @return The equivalent value in the convertible derived unit. * @throws ConversionException * Can't convert between units. */ public double toDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(amount + getOffset()); }
/** * Converts a value in the convertible derived unit to the equivalent value * in this unit. * * @param amount * The value in the convertible derived unit. * @return The equivalent value in this unit. * @throws ConversionException * Can't convert between units. */ public double fromDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } return ((DerivableUnit) getUnit()).fromDerivedUnit(amount) - getOffset(); }
/** * Converts values in this unit to the equivalent values in the convertible * derived unit. * * @param input * The values in this unit. * @param output * The equivalent values in the convertible derived unit. May be * the same array as <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public double[] toDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } final double origin = getOffset(); for (int i = input.length; --i >= 0;) { output[i] = input[i] + origin; } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts values in this unit to the equivalent values in the convertible * derived unit. * * @param input * The values in this unit. * @param output * The equivalent values in the convertible derived unit. May be * the same array as <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public float[] toDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } final float origin = (float) getOffset(); for (int i = input.length; --i >= 0;) { output[i] = input[i] + origin; } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts values in this unit to the equivalent values in the convertible * derived unit. * * @param input * The values in this unit. * @param output * The equivalent values in the convertible derived unit. May be * the same array as <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public double[] toDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } final double origin = getOffset(); for (int i = input.length; --i >= 0;) { output[i] = input[i] + origin; } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts values in this unit to the equivalent values in the convertible * derived unit. * * @param input * The values in this unit. * @param output * The equivalent values in the convertible derived unit. May be * the same array as <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public float[] toDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } final float origin = (float) getOffset(); for (int i = input.length; --i >= 0;) { output[i] = input[i] + origin; } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts values in the convertible derived unit to the equivalent values * in this unit. * * @param input * The values in the convertible derived unit. * @param output * The equivalent values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public float[] fromDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final float origin = (float) getOffset(); for (int i = input.length; --i >= 0;) { output[i] -= origin; } return output; }
/** * Converts values in the convertible derived unit to the equivalent values * in this unit. * * @param input * The values in the convertible derived unit. * @param output * The equivalent values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public double[] fromDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final double origin = getOffset(); for (int i = input.length; --i >= 0;) { output[i] -= origin; } return output; }
/** * Converts values in the convertible derived unit to the equivalent values * in this unit. * * @param input * The values in the convertible derived unit. * @param output * The equivalent values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public float[] fromDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final float origin = (float) getOffset(); for (int i = input.length; --i >= 0;) { output[i] -= origin; } return output; }
/** * Converts values in the convertible derived unit to the equivalent values * in this unit. * * @param input * The values in the convertible derived unit. * @param output * The equivalent values in this unit. May be the same array as * <code>input</code>. * @return <code>output</code>. * @throws ConversionException * Can't convert between units. */ public double[] fromDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final double origin = getOffset(); for (int i = input.length; --i >= 0;) { output[i] -= origin; } return output; }