Package javax.measure

Class VectorMeasure<Q extends Quantity>

  • All Implemented Interfaces:
    Serializable, Comparable<Measurable<Q>>, Measurable<Q>

    public abstract class VectorMeasure<Q extends Quantity>
    extends Measure<double[],​Q>

    This class represents a measurement vector of two or more dimensions. For example:[code] VectorMeasure dimension = VectorMeasure.valueOf(12.0, 30.0, 40.0, MILLIMETER); VectorMeasure v2d = VectorMeasure.valueOf(-2.2, -3.0, KNOTS); VectorMeasure c2d = VectorMeasure.valueOf(-7.3, 3.5, NANOAMPERE); [/code]

    Subclasses may provide fixed dimensions specializations:[code] class Velocity2D extends VectorMeasure { public Velocity2D(double x, double y, Unit unit) { ... } } [/code]

    Measurement vectors may use compound units:[code] VectorMeasure latLong = VectorMeasure.valueOf(12.345, 22.23, DEGREE_ANGLE); Unit 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"] [/code]

    Instances of this class (and sub-classes) are immutable.

    See Also:
    Serialized Form
    • Constructor Detail

      • VectorMeasure

        protected VectorMeasure()
        Default constructor (for sub-classes).
    • Method Detail

      • valueOf

        public static <Q extends QuantityVectorMeasure<Q> valueOf​(double x,
                                                                    double y,
                                                                    Unit<Q> unit)
        Returns a 2-dimensional measurement vector.
        Parameters:
        x - the first vector component value.
        y - the second vector component value.
        unit - the measurement unit.
      • valueOf

        public static <Q extends QuantityVectorMeasure<Q> valueOf​(double x,
                                                                    double y,
                                                                    double z,
                                                                    Unit<Q> unit)
        Returns a 3-dimensional measurement vector.
        Parameters:
        x - the first vector component value.
        y - the second vector component value.
        z - the third vector component value.
        unit - the measurement unit.
      • valueOf

        public static <Q extends QuantityVectorMeasure<Q> valueOf​(double[] components,
                                                                    Unit<Q> unit)
        Returns a multi-dimensional measurement vector.
        Parameters:
        components - the vector component values.
        unit - the measurement unit.
      • to

        public abstract VectorMeasure<Q> to​(Unit<Q> unit)
        Returns the measurement vector equivalent to this one but stated in the specified unit.
        Specified by:
        to in class Measure<double[],​Q extends Quantity>
        Parameters:
        unit - the new measurement unit.
        Returns:
        the vector measure stated in the specified unit.
      • doubleValue

        public abstract double doubleValue​(Unit<Q> unit)
        Returns the norm of this measurement vector stated in the specified unit.
        Specified by:
        doubleValue in interface Measurable<Q extends Quantity>
        Specified by:
        doubleValue in class Measure<double[],​Q extends Quantity>
        Parameters:
        unit - the unit in which the norm is stated.
        Returns:
        |this|
      • toString

        public String toString()
        Returns the String representation of this measurement vector (for example [2.3 m/s, 5.6 m/s]).
        Overrides:
        toString in class Measure<double[],​Q extends Quantity>
        Returns:
        the textual representation of the measurement vector.