Unit
UnitRatio
public class CompoundUnit extends java.lang.Object implements Unit
new CompoundUnit(new Unit[] {Newton.UNIT, Meter.UNIT}, new double[] {1.0,-1.0});
Constructor | Description |
---|---|
CompoundUnit(Unit[] units,
double[] exponents) |
Constructs unit with default name and abbreviation constructed from given units and exponents
|
CompoundUnit(Unit[] units,
double[] exponents,
java.lang.String name,
java.lang.String symbol) |
Modifier and Type | Method | Description |
---|---|---|
Dimension |
dimension() |
Returns the dimension of the unit.
|
double |
fromSim(double x) |
Takes the given value in simulation units and converts it to class units (considering prefix).
|
boolean |
prefixAllowed() |
Indicates if the unit is appropriate for use with a prefix.
|
java.lang.String |
symbol() |
Returns the symbol of unit, such as "g" for grams.
|
double |
toSim(double x) |
Takes the given value in class units (considering prefix) and converts it to simulation units.
|
public CompoundUnit(Unit[] units, double[] exponents)
units
- array of units used to specify this unitexponents
- array exponents associated with each unit.java.lang.IllegalArgumentException
- if argument arrays are of different lengthpublic CompoundUnit(Unit[] units, double[] exponents, java.lang.String name, java.lang.String symbol)
units
- list of units used to specify this unitexponents
- exponents associated with each unitname
- a common name used to reference this unit (e.g., Newton)symbol
- an abbreviated name used to reference this unit (e.g., N)java.lang.IllegalArgumentException
- if units and exponents arrays are of different lengthpublic Dimension dimension()
Unit
public double toSim(double x)
Unit
public double fromSim(double x)
Unit
public java.lang.String symbol()
Unit
public boolean prefixAllowed()
Unit
prefixAllowed
in interface Unit