javax.measure
Q
- The quantity of the vector (e.g. Power)public abstract class VectorMeasure<Q extends Quantity> extends Measure<double[],Q>
VectorMeasure<Length> dimension = VectorMeasure.valueOf(12.0, 30.0, 40.0, MILLIMETER); VectorMeasure<Velocity> v2d = VectorMeasure.valueOf(-2.2, -3.0, KNOTS); VectorMeasure<ElectricCurrent> c2d = VectorMeasure.valueOf(-7.3, 3.5, NANOAMPERE);Subclasses may provide fixed dimensions specializations:
class Velocity2D extends VectorMeasure<Velocity> { public Velocity2D(double x, double y, Unit<Velocity> unit) { ... } }Measurement vectors may use
compound units
:
VectorMeasure<Angle> latLong = VectorMeasure.valueOf(12.345, 22.23, DEGREE_ANGLE); Unit<Angle> HOUR_MINUTE_SECOND_ANGLE = DEGREE_ANGLE.compound(MINUTE_ANGLE).compound(SECOND_ANGLE); System.out.println(latLong.to(HOUR_MINUTE_SECOND_ANGLE)); > [12°19'42", 22°12'48"]Instances of this class (and sub-classes) are immutable.
Modifier | Constructor and Description |
---|---|
protected |
VectorMeasure()
Default constructor (for sub-classes).
|
Modifier and Type | Method and Description |
---|---|
Measurable<Q> |
add(Measurable<Q> other)
Adds the other Measurable to this one, returning a Measurable object of the same type as the original.
|
abstract double |
doubleValue(Unit<Q> unit)
Returns the norm of this measurement vector stated in the specified unit.
|
abstract VectorMeasure<Q> |
to(Unit<Q> unit)
Returns the measurement vector equivalent to this one but stated in the specified unit.
|
java.lang.String |
toString()
Returns the
String representation of this measurement vector (for example
[2.3 m/s, 5.6 m/s] ). |
static <Q extends Quantity> |
valueOf(double[] components,
Unit<Q> unit)
Returns a multi-dimensional measurement vector.
|
static <Q extends Quantity> |
valueOf(double x,
double y,
double z,
Unit<Q> unit)
Returns a 3-dimensional measurement vector.
|
static <Q extends Quantity> |
valueOf(double x,
double y,
Unit<Q> unit)
Returns a 2-dimensional measurement vector.
|
public Measurable<Q> add(Measurable<Q> other)
Measurable
other
- The measurable that should be added to this one.public static <Q extends Quantity> VectorMeasure<Q> valueOf(double x, double y, Unit<Q> unit)
x
- the first vector component value.y
- the second vector component value.unit
- the measurement unit.public static <Q extends Quantity> VectorMeasure<Q> valueOf(double x, double y, double z, Unit<Q> unit)
x
- the first vector component value.y
- the second vector component value.z
- the third vector component value.unit
- the measurement unit.public static <Q extends Quantity> VectorMeasure<Q> valueOf(double[] components, Unit<Q> unit)
components
- the vector component values.unit
- the measurement unit.public abstract VectorMeasure<Q> to(Unit<Q> unit)
public abstract double doubleValue(Unit<Q> unit)
doubleValue
in interface Measurable<Q extends Quantity>
doubleValue
in class Measure<double[],Q extends Quantity>
unit
- the unit in which the norm is stated.|this|