public final class DerivedUnit extends Unit implements Serializable
| Constructor and Description |
|---|
DerivedUnit()
Construct a dimensionless derived unit.
|
DerivedUnit(BaseUnit baseUnit)
Construct a derived unit from a base unit.
|
DerivedUnit(BaseUnit[] baseUnits,
int[] powers)
Construct a derived unit from an array base units and powers.
|
DerivedUnit(BaseUnit[] baseUnits,
int[] powers,
String identifier)
Construct a derived unit from an array base units, powers, and an
identifier.
|
DerivedUnit(DerivedUnit that,
String identifier)
Construct a derived unit from a derived unit and an identifier.
|
DerivedUnit(String identifier)
Construct a dimensionless derived unit with an identifier.
|
| Modifier and Type | Method and Description |
|---|---|
Unit |
divide(Unit that)
Divide a derived unit by another unit.
|
protected Unit |
divideInto(Unit that)
Divide a derived unit into another unit.
|
boolean |
equals(Unit unit)
Indicates if this instance equals a unit.
|
String |
getDefinition()
Return the definition of this unit.
|
DerivedUnit |
getDerivedUnit()
Returns the derived unit that underlies this unit.
|
int |
hashCode()
Returns the hash code of this instance.
|
boolean |
isConvertible(Unit unit)
Indicate whether this unit is convertible with another unit.
|
boolean |
isDimensionless()
Indicates if this instance is dimensionless.
|
Unit |
log(double base)
Returns the logarithmic unit that has this unit as its reference level.
|
static void |
main(String[] args)
Test this class.
|
Unit |
multiply(DerivedUnit that)
Multiply a derived unit by a derived unit.
|
Unit |
multiply(Unit that)
Multiply a derived unit by another unit.
|
protected static visad.Factor[] |
newFactors(BaseUnit[] baseUnits,
int[] powers)
Creates an array of Factor-s from arrays of base units and powers.
|
Unit |
pow(double power)
Raise a derived unit to a power.
|
Unit |
pow(int power)
Raise a derived unit to a power.
|
protected Unit |
protectedClone(String identifier)
Clones this unit, changing the identifier.
|
Unit |
root(int root)
Returns the N-th root of this unit.
|
Unit |
scale(double amount)
Scale this unit by an amount.
|
Unit |
shift(double offset)
Shift this unit by an amount.
|
double[] |
toThat(double[] values,
Unit that)
Convert values from this unit to another unit.
|
double[] |
toThat(double[] values,
Unit that,
boolean copy)
Convert values from this unit to another unit.
|
float[] |
toThat(float[] values,
Unit that)
Convert values from this unit to another unit.
|
float[] |
toThat(float[] values,
Unit that,
boolean copy)
Convert values from this unit to another unit.
|
double[] |
toThis(double[] values,
Unit that)
Convert values to this unit from another unit.
|
double[] |
toThis(double[] values,
Unit that,
boolean copy)
Convert values to this unit from another unit.
|
float[] |
toThis(float[] values,
Unit that)
Convert values to this unit from another unit.
|
float[] |
toThis(float[] values,
Unit that,
boolean copy)
Convert values to this unit from another unit.
|
adjustCheckAndCache, canConvert, canConvertArray, clone, convertTuple, convertTuple, convertTuple, convertTuple, copyUnitsArray, equals, getAbsoluteUnit, getIdentifier, sqrt, toString, toThat, toThis, transformUnits, transformUnits, transformUnits, transformUnitspublic DerivedUnit()
public DerivedUnit(String identifier)
identifier - Name or abbreviation for the unit. May be null or
empty.public DerivedUnit(BaseUnit baseUnit)
baseUnit - The base unit.public DerivedUnit(BaseUnit[] baseUnits, int[] powers)
null.baseUnits - The array of base units (e.g. {m, s}).powers - The array of powers (e.g. {1, -1} to create a m/s unit).public DerivedUnit(BaseUnit[] baseUnits, int[] powers, String identifier)
baseUnits - The array of base units (e.g. {m, s}).powers - The array of powers (e.g. {1, -1} to create a m/s unit).identifier - Name or abbreviation for the unit. May be null or
empty.public DerivedUnit(DerivedUnit that, String identifier)
that - The derived unit.identifier - Name or abbreviation for the unit. May be null or
empty.protected static visad.Factor[] newFactors(BaseUnit[] baseUnits, int[] powers)
baseUnits - The array of base units (e.g. {m, s}).powers - The array of powers (e.g. {1, -1} to create a m/s unit).Factors equivalent to the given base units
and powers.public boolean isDimensionless()
Indicates if this instance is dimensionless. A unit is dimensionless if it is a measure of a dimensionless quantity like angle or concentration. Examples of dimensionless units include radian, degree, steradian, and "g/kg".
isDimensionless in class Unitprotected Unit protectedClone(String identifier)
protectedClone in class Unitidentifier - The name or abbreviation for the cloned unit. May be
null or empty.public Unit scale(double amount) throws UnitException
scale in class Unitamount - The amount by which to scale this unit. E.g. Unit yard =
meter.scale(0.9144);UnitException - This unit cannot be scaled.public Unit shift(double offset) throws UnitException
shift in class Unitoffset - The amount by which to shift this unit. E.g. Unit celsius =
kelvin.shift(273.15);UnitException - The unit subclass is unknown.public Unit log(double base)
Unitpublic Unit pow(int power)
public Unit root(int root) throws IllegalArgumentException
root in class Unitroot - The root to take (e.g. 2 means square root). May not be zero.root-th root of this
unit.IllegalArgumentException - root is zero or the result would have a
non-integral unit dimension.public Unit pow(double power) throws IllegalArgumentException
pow in class Unitpower - The power to raise this unit by. If this unit is not
dimensionless, then the value must be an integer or the
reciprocal of an integer.power.IllegalArgumentException - This unit is not dimensionless and power
is neither an integer nor the reciprocal of an integer.public String getDefinition()
getDefinition in class Unitpublic static void main(String[] args) throws UnitException
args - Arguments (ignored).UnitException - A problem occurred.public Unit multiply(Unit that) throws UnitException
multiply in class Unitthat - The unit with which to multiply this unit.UnitException - Meaningless operation.public Unit multiply(DerivedUnit that)
that - The derived unit with which to multiply this unit.public Unit divide(Unit that) throws UnitException
divide in class Unitthat - The unit to divide into this unit.UnitException - Meaningless operation.protected Unit divideInto(Unit that) throws UnitException
divideInto in class Unitthat - The unit to be divided by this unit.UnitException - Meaningless operation.public double[] toThis(double[] values,
Unit that)
throws UnitException
toThis in class Unitvalues - The values to be converted.that - The unit of values.UnitException - The units are not convertible.public float[] toThis(float[] values,
Unit that)
throws UnitException
toThis in class Unitvalues - The values to be converted.that - The unit of values.UnitException - The units are not convertible.public double[] toThis(double[] values,
Unit that,
boolean copy)
throws UnitException
toThis in class Unitvalues - The values to be converted.that - The unit of values.copy - if false and that equals this, return
values, else return a new arrayUnitException - The units are not convertible.public float[] toThis(float[] values,
Unit that,
boolean copy)
throws UnitException
toThis in class Unitvalues - The values to be converted.that - The unit of values.copy - if false and that equals this, return
values, else return a new arrayUnitException - The units are not convertible.public double[] toThat(double[] values,
Unit that)
throws UnitException
toThat in class Unitvalues - The values to be converted in units of this unit.that - The unit to which to convert the values.UnitException - The units are not convertible.public float[] toThat(float[] values,
Unit that)
throws UnitException
toThat in class Unitvalues - The values to be converted in units of this unit.that - The unit to which to convert the values.UnitException - The units are not convertible.public double[] toThat(double[] values,
Unit that,
boolean copy)
throws UnitException
toThat in class Unitvalues - The values to be converted in units of this unit.that - The unit to which to convert the values.copy - if false and that equals this, return
values, else return a new arrayUnitException - The units are not convertible.public float[] toThat(float[] values,
Unit that,
boolean copy)
throws UnitException
toThat in class Unitvalues - The values to be converted in units of this unit.that - The unit to which to convert the values.copy - if false and that equals this, return
values, else return a new arrayUnitException - The units are not convertible.public boolean isConvertible(Unit unit)
toThis(...)/ and
toThat(...) methods will not throw a UnitException. Unit A
is convertible with unit B if and only if unit B is convertible with unit
A; hence, calling-order is irrelevant.isConvertible in class Unitunit - The other unit.public boolean equals(Unit unit)
public int hashCode()
Object.hashCode() should
be overridden whenever Object.equals(Object) is.public DerivedUnit getDerivedUnit()
UnitgetDerivedUnit in class UnitCopyright © 1996–2023 The SSEC Visualization Project. All rights reserved.