All Packages Class Hierarchy This Package Previous Next Index
Class units.Unit
java.lang.Object
|
+----units.Unit
- public class Unit
- extends Object
- implements Cloneable, Serializable
This class embodies the pair <v, u> and
is used directly by the application programmer. It has a parser
that generates the internal representation from the character
string expression of a unit. It also provides all the operators to
calculate with units, multiplication, division and raising to a
power.
- Version:
- $Id: Unit.java,v 1.4 1998/08/31 23:42:57 schadow Exp schadow $
- Author:
- Gunther Schadow
-
cnv
-
-
cnv_pfx
- This provides for the SI anomality of allowing prefixes on
the Degree celsius.
-
name
-
-
nu
-
-
u_vec
-
-
Unit()
- Instantiate the Unit "" = 1 (the unity)
-
Unit(String)
- Parse a unit term
-
Unit(String, double, Dimension)
- Instantiate a unit <nu, u_vec> with name.
-
Unit(String, double, Dimension, Function, double)
- Instantiate a unit <nu, u_vec> with name and conversion functions.
-
assign(Unit)
- Sets this unit to be equal to another unit u.
-
assignUnity()
- Assign the unity (= dimensionless unit 1) to this unit.
-
caseSensitive()
-
-
caseSensitive(boolean)
-
-
clone()
-
-
convertCoherent(double)
- Converts measurement mu * this unit into a coherent unit.
-
convertFrom(double, Unit)
- Converts a measurement mu * u into this unit.
-
convertTo(double, Unit)
- Converts a measurement mu * this unit into other unit u.
-
dim()
- Returns the dimension of this unit
-
div(Unit)
- Divides this unit u1 with another unit u2.
-
dump()
-
-
equals(Unit)
- Tests for equality of this unit u1 and another unit u2.
-
inv()
- Invert this unit with respect to multiplication.
-
mul(double)
- Multiplies this unit u with a scalar s.
-
mul(Unit)
- Multiplies this unit u1 with another unit u2.
-
mutateCoherent(double)
- Mutates this unit into a coherent unit and converts a measurement mu
-
mutateRatio(double)
- Mutates this unit into a unit on a ratio scale and converts measurement mu
-
pow(int)
- Raises this unit u to a power p.
-
toString()
- Returns the string representation (i.e.
name
protected String name
nu
protected double nu
u_vec
protected Dimension u_vec
cnv
protected Function cnv
cnv_pfx
protected double cnv_pfx
- This provides for the SI anomality of allowing prefixes on
the Degree celsius.
Unit
public Unit()
- Instantiate the Unit "" = 1 (the unity)
Unit
public Unit(String _name,
double _nu,
Dimension _u_vec,
Function _cnv,
double _cnv_pfx)
- Instantiate a unit <nu, u_vec> with name and conversion functions.
Unit
public Unit(String _name,
double _nu,
Dimension _u_vec)
- Instantiate a unit <nu, u_vec> with name.
Unit
public Unit(String term)
- Parse a unit term
caseSensitive
public static void caseSensitive(boolean cs)
caseSensitive
public static boolean caseSensitive()
clone
public Object clone()
- Overrides:
- clone in class Object
equals
public boolean equals(Unit u2)
- Tests for equality of this unit u1 and another unit u2.
- Returns:
- true if u1 and u2 are equal, false otherwise.
assign
public Unit assign(Unit u)
- Sets this unit to be equal to another unit u.
- Returns:
- this unit after assignment to u
assignUnity
public Unit assignUnity()
- Assign the unity (= dimensionless unit 1) to this unit.
dim
public Dimension dim()
- Returns the dimension of this unit
toString
public String toString()
- Returns the string representation (i.e. the name) of the unit
- Overrides:
- toString in class Object
dump
public void dump()
convertFrom
public double convertFrom(double mu1,
Unit u1)
- Converts a measurement mu * u into this unit.
- Returns:
- the converted measurement value
- Throws: IllegalArgumentException
- if dimensions differ.
convertTo
public double convertTo(double mu,
Unit u)
- Converts a measurement mu * this unit into other unit u.
- Returns:
- the converted measurement value
- Throws: IllegalArgumentException
- if dimensions differ.
convertCoherent
public double convertCoherent(double mu)
- Converts measurement mu * this unit into a coherent unit.
- Returns:
- the converted measurement value
- Throws: IllegalArgumentException
- if dimensions differ.
mutateCoherent
public double mutateCoherent(double mu)
- Mutates this unit into a coherent unit and converts a measurement mu
- Returns:
- the converted measurement value
- Throws: IllegalArgumentException
- if dimensions differ.
mutateRatio
public double mutateRatio(double mu)
- Mutates this unit into a unit on a ratio scale and converts measurement mu
- Returns:
- the converted measurement value
- Throws: IllegalArgumentException
- if dimensions differ.
mul
public Unit mul(double s)
- Multiplies this unit u with a scalar s. Special meaning for
special units so that (0.1*B) is 1 dB.
- Returns:
- the product u * s.
- Throws: IllegalArgumentException
- if u is on a non-ratio scale.
mul
public Unit mul(Unit u2)
- Multiplies this unit u1 with another unit u2. If one of the
factors is a non-ratio unit the other must be dimensionless or
else an exception is raised. This special case treatment allows
to scale non-ratio units.
- Returns:
- the product u1 * u2
- Throws: IllegalArgumentException
- if one of the unit is not on
a ratio-scale and the other is not dimensionless.
div
public Unit div(Unit u2)
- Divides this unit u1 with another unit u2. If u1 is not on a
ratio scale an exception is raised. Mutating to a ratio scale unit
is not possible for a unit, only for a measurement.
- Returns:
- the quotient u1 / u2
- Throws: IllegalArgumentException
- if a unit is not on a ratio-scale.
inv
public Unit inv()
- Invert this unit with respect to multiplication. If u1 is not on a
ratio scale an exception is raised. Mutating to a ratio scale unit
is not possible for a unit, only for a measurement.
- Returns:
- 1/u.
- Throws: IllegalArgumentException
- if u is not on a ratio-scale.
pow
public Unit pow(int p)
- Raises this unit u to a power p. If u1 is not on a
ratio scale an exception is raised. Mutating to a ratio scale unit
is not possible for a unit, only for a measurement.
- Returns:
- the power u^p.
- Throws: IllegalArgumentException
- if u is not on a ratio-scale.
All Packages Class Hierarchy This Package Previous Next Index