@Override public UnitConverter toStandardUnit() { return _low.toStandardUnit(); }
@Override public UnitConverter toStandardUnit() { return _low.toStandardUnit(); }
@Override public UnitConverter toStandardUnit() { return _low.toStandardUnit(); }
public UnitConverter toStandardUnit() { return _parentUnit.toStandardUnit().concatenate(_toParentUnit); }
public UnitConverter toStandardUnit() { return _parentUnit.toStandardUnit().concatenate(_toParentUnit); }
public UnitConverter toStandardUnit() { return _parentUnit.toStandardUnit().concatenate(_toParentUnit); }
/** * Returns a converter of numeric values from this unit to another unit. * * @param that the unit to which to convert the numeric values. * @return the converter from this unit to <code>that</code> unit. * @throws ConversionException if the conveter cannot be constructed * (e.g. <code>!this.isCompatible(that)</code>). */ public final UnitConverter getConverterTo(Unit<?> that) throws ConversionException { if (this.equals(that)) return UnitConverter.IDENTITY; Unit<?> thisSystemUnit = this.getStandardUnit(); Unit<?> thatSystemUnit = that.getStandardUnit(); if (thisSystemUnit.equals(thatSystemUnit)) return that.toStandardUnit().inverse().concatenate( this.toStandardUnit()); // Use dimensional transforms. if (!thisSystemUnit.getDimension() .equals(thatSystemUnit.getDimension())) throw new ConversionException(this + " is not compatible with " + that); // Transform between SystemUnit and BaseUnits is Identity. UnitConverter thisTransform = this.toStandardUnit().concatenate( transformOf(this.getBaseUnits())); UnitConverter thatTransform = that.toStandardUnit().concatenate( transformOf(that.getBaseUnits())); return thatTransform.inverse().concatenate(thisTransform); }
/** * Returns a converter of numeric values from this unit to another unit. * * @param that the unit to which to convert the numeric values. * @return the converter from this unit to <code>that</code> unit. * @throws ConversionException if the conveter cannot be constructed * (e.g. <code>!this.isCompatible(that)</code>). */ public final UnitConverter getConverterTo(Unit<?> that) throws ConversionException { if (this.equals(that)) return UnitConverter.IDENTITY; Unit<?> thisSystemUnit = this.getStandardUnit(); Unit<?> thatSystemUnit = that.getStandardUnit(); if (thisSystemUnit.equals(thatSystemUnit)) return that.toStandardUnit().inverse().concatenate( this.toStandardUnit()); // Use dimensional transforms. if (!thisSystemUnit.getDimension() .equals(thatSystemUnit.getDimension())) throw new ConversionException(this + " is not compatible with " + that); // Transform between SystemUnit and BaseUnits is Identity. UnitConverter thisTransform = this.toStandardUnit().concatenate( transformOf(this.getBaseUnits())); UnitConverter thatTransform = that.toStandardUnit().concatenate( transformOf(that.getBaseUnits())); return thatTransform.inverse().concatenate(thisTransform); }
/** * Returns a converter of numeric values from this unit to another unit. * * @param that the unit to which to convert the numeric values. * @return the converter from this unit to <code>that</code> unit. * @throws ConversionException if the conveter cannot be constructed * (e.g. <code>!this.isCompatible(that)</code>). */ public final UnitConverter getConverterTo(Unit<?> that) throws ConversionException { if (this.equals(that)) return UnitConverter.IDENTITY; Unit<?> thisSystemUnit = this.getStandardUnit(); Unit<?> thatSystemUnit = that.getStandardUnit(); if (thisSystemUnit.equals(thatSystemUnit)) return that.toStandardUnit().inverse().concatenate( this.toStandardUnit()); // Use dimensional transforms. if (!thisSystemUnit.getDimension() .equals(thatSystemUnit.getDimension())) throw new ConversionException(this + " is not compatible with " + that); // Transform between SystemUnit and BaseUnits is Identity. UnitConverter thisTransform = this.toStandardUnit().concatenate( transformOf(this.getBaseUnits())); UnitConverter thatTransform = that.toStandardUnit().concatenate( transformOf(that.getBaseUnits())); return thatTransform.inverse().concatenate(thisTransform); }
@Override public UnitConverter toStandardUnit() { if (hasOnlyStandardUnit()) return UnitConverter.IDENTITY; UnitConverter converter = UnitConverter.IDENTITY; for (int i = 0; i < _elements.length; i++) { UnitConverter cvtr = _elements[i]._unit.toStandardUnit(); if (!cvtr.isLinear()) throw new ConversionException(_elements[i]._unit + " is non-linear, cannot convert"); if (_elements[i]._root != 1) throw new ConversionException(_elements[i]._unit + " holds a base unit with fractional exponent"); int pow = _elements[i]._pow; if (pow < 0) { // Negative power. pow = -pow; cvtr = cvtr.inverse(); } for (int j = 0; j < pow; j++) { converter = converter.concatenate(cvtr); } } return converter; }
@Override public UnitConverter toStandardUnit() { if (hasOnlyStandardUnit()) return UnitConverter.IDENTITY; UnitConverter converter = UnitConverter.IDENTITY; for (int i = 0; i < _elements.length; i++) { UnitConverter cvtr = _elements[i]._unit.toStandardUnit(); if (!cvtr.isLinear()) throw new ConversionException(_elements[i]._unit + " is non-linear, cannot convert"); if (_elements[i]._root != 1) throw new ConversionException(_elements[i]._unit + " holds a base unit with fractional exponent"); int pow = _elements[i]._pow; if (pow < 0) { // Negative power. pow = -pow; cvtr = cvtr.inverse(); } for (int j = 0; j < pow; j++) { converter = converter.concatenate(cvtr); } } return converter; }
@Override public UnitConverter toStandardUnit() { if (hasOnlyStandardUnit()) return UnitConverter.IDENTITY; UnitConverter converter = UnitConverter.IDENTITY; for (int i = 0; i < _elements.length; i++) { UnitConverter cvtr = _elements[i]._unit.toStandardUnit(); if (!cvtr.isLinear()) throw new ConversionException(_elements[i]._unit + " is non-linear, cannot convert"); if (_elements[i]._root != 1) throw new ConversionException(_elements[i]._unit + " holds a base unit with fractional exponent"); int pow = _elements[i]._pow; if (pow < 0) { // Negative power. pow = -pow; cvtr = cvtr.inverse(); } for (int j = 0; j < pow; j++) { converter = converter.concatenate(cvtr); } } return converter; }