Comparable<UV>
public class UV extends Object implements Comparable<UV>
A compound unit with a value. This value is not the same as unit length.
Unit vectors with different units can be multiplied and divided. The result will have correct unit and length. Unit vector can easily be converted to any unit with the same total quantity.
Ex: 1 m / 2 seconds = 0.5 m/s = 1.8 km/h != 0.5 kg/s
Modifier and Type | Method | Description |
---|---|---|
UV |
add(double value,
U u) |
Like
add(UV uv) but the UnitValue to add is specified as a value and a Unit. |
UV |
add(UV uv) |
Adds another UnitValue to this one and returns the resulting UnitValue.
|
int |
compareTo(UV uv) |
|
UV |
convert(U to) |
Converts this UnitValue to another Unit.
|
UV |
convertAbsolute(U to) |
Converts this unit while accounting for offset.
|
UV |
convertAuto(double target) |
Calculates and returns the unit most appropriate for displaying a given value.
|
UV |
div(double value,
U u) |
Like
div(UV uv) but the UnitValue to divide with is specified as a value and a Unit. |
UV |
div(UV uv) |
Divides this UnitValue with another and returns the resulting UnitValue.
|
boolean |
equals(Object obj) |
|
UV |
inverse() |
Invert this UnitValue.
|
static UV |
max(UV a,
UV b) |
Compares two compatible unit vectors and returns the largest of them.
|
static UV |
min(UV a,
UV b) |
Compares two compatible unit vectors and returns the smallest of them.
|
UV |
mul(double value,
U u) |
Like
mul(UV uv) but the UnitValue to multiply with is specified as a value and a Unit. |
UV |
mul(UV uv) |
Multiplies another UnitValue with this one and returns the resulting UnitValue.
|
UV |
negate() |
Negate this UnitValue.
|
UV |
negatePercent() |
Negate this UnitValue as a percentage.
|
UV |
pow(double p) |
Raise this UnitValue to a power.
|
void |
set(UV uv) |
Sets this UV to be a copy of another UV.
|
UV |
sub(double value,
U u) |
Like
sub(UV uv) but the UnitValue to subtract is specified as a value and a Unit. |
UV |
sub(UV uv) |
Subtracts another UnitValue from this one and returns the resulting UnitValue.
|
String |
toString() |
|
U |
unit() |
Returns the Unit of this UnitValue.
|
double |
value() |
Returns the value of this UnitValue in the Unit it is currently in.
|
public UV convert(U to) throws UnitMismatchException
to
- the Unit to convert to.UnitMismatchException
- If this unit can't be converted to the target unit. (If they don't share the same quantity.)public UV convertAbsolute(U to) throws UnitMismatchException
to
- the Unit to convert to.UnitMismatchException
- if this unit cannot be converted to the target one.public UV add(UV uv) throws UnitMismatchException
uv
- the UnitValue to add to this one.UnitMismatchException
- if the Units of the UnitValues are not of the same Quantity.public UV add(double value, U u) throws UnitMismatchException
add(UV uv)
but the UnitValue to add is specified as a value and a Unit.UnitMismatchException
public UV sub(UV uv) throws UnitMismatchException
uv
- the UnitValue to subtract from this one.UnitMismatchException
- if the Units of the UnitValues are not of the same Quantity.public UV sub(double value, U u) throws UnitMismatchException
sub(UV uv)
but the UnitValue to subtract is specified as a value and a Unit.UnitMismatchException
public UV mul(UV uv)
uv
- the UnitValue to multiply with this one.public UV mul(double value, U u)
mul(UV uv)
but the UnitValue to multiply with is specified as a value and a Unit.public UV div(UV uv)
uv
- the UnitValue to divide this one by.public UV div(double value, U u)
div(UV uv)
but the UnitValue to divide with is specified as a value and a Unit.public UV pow(double p)
p
- the value to raise this UnitValue to.public UV inverse()
public UV negate()
public UV negatePercent()
public static UV max(UV a, UV b) throws UnitMismatchException
a
- first unit vectorb
- second unit vectorUnitMismatchException
- if units are not of the same quantity.public static UV min(UV a, UV b) throws UnitMismatchException
a
- first unit vectorb
- second unit vectorUnitMismatchException
- if units are not of the same quantity.public double value()
public U unit()
public void set(UV uv)
uv
- the unit vector to set this unit vector topublic int compareTo(UV uv)
compareTo
in interface Comparable<UV>
public UV convertAuto(double target)
target
- target value of the numeric part of this unit.Copyright © 2018. All rights reserved.