Package geomss.geom

Class GeomVector<Q extends javax.measure.quantity.Quantity>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int X
      Constant used to identify the X coordinate in a 3D vector.
      static int Y
      Constant used to identify the Y coordinate in a 3D vector.
      static int Z
      Constant used to identify the Z coordinate in a 3D vector.
    • Constructor Summary

      Constructors 
      Constructor Description
      GeomVector()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      Parameter<javax.measure.quantity.Angle> angle​(GeomVector<?> that)
      Returns the angle between this vector and the specified vector.
      abstract GeomVector<Q> copy()
      Returns a copy of this GeomVector instance allocated by the calling thread (possibly on the stack).
      abstract Vector<? extends javax.measure.quantity.Quantity> cross​(GeomVector<?> that)
      Returns the cross product of two vectors.
      abstract Vector<Q> divide​(double divisor)
      Returns this vector with each element divided by the specified divisor (dimensionless).
      abstract Vector<? extends javax.measure.quantity.Quantity> divide​(Parameter<?> that)
      Returns this vector with each element divided by the specified divisor.
      Parameter<? extends javax.measure.quantity.Quantity> dot​(GeomVector<?> that)
      Returns the dot product (scalar product) of this vector with the one specified.
      Parameter<Q> get​(int i)
      Returns the value of a Parameter from this vector.
      Point getBoundsMax()
      Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).
      Point getBoundsMin()
      Return the coordinate point representing the minimum bounding box corner (e.g.: min X, min Y, min Z).
      Point getLimitPoint​(int dim, boolean max, double tol)
      Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this geometry element.
      abstract Point getOrigin()
      Return the origin point for this vector.
      int getParDimension()
      Returns the number of parametric dimensions of the geometry element.
      VectorTrans<Q> getTransformed​(GTransform transform)
      Returns transformed version of this element.
      abstract double getValue​(int i)
      Returns the value of the Parameter in this vector as a double, stated in this vector's unit.
      abstract double getValue​(int i, javax.measure.unit.Unit<Q> unit)
      Returns the value of the Parameter in this vector as a double, stated in the specified units.
      abstract Vector<Q> immutable()
      Return an immutable version of this vector.
      boolean isApproxEqual​(GeomVector obj)
      Compares this vector against the specified vector for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).
      boolean isApproxEqual​(GeomVector obj, Parameter<Q> tol)
      Compares this vector against the specified vector for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance).
      boolean isValid()
      Return true if this GeomVector contains valid and finite numerical components.
      Parameter<Q> mag()
      Returns the Euclidian norm, magnitude, or length of this vector (square root of the dot product of this vector and itself).
      double magValue()
      Returns the norm(), magnitude, or length value of this vector.
      abstract Vector<Q> minus​(GeomVector<Q> that)
      Returns the difference between this vector and the one specified.
      abstract Vector<Q> minus​(Parameter<Q> that)
      Subtracts the supplied Parameter from each element of this vector and returns the result.
      Parameter<Q> norm()
      Returns the Euclidian norm, magnitude, or length of this vector (square root of the dot product of this vector and itself).
      abstract double normValue()
      Returns the norm(), magnitude, or length value of this vector (square root of the dot product of this vector and itself).
      abstract Vector<Q> opposite()
      Returns the negation of this vector.
      abstract Vector<Q> plus​(GeomVector<Q> that)
      Returns the sum of this vector with the one specified.
      abstract Vector<Q> plus​(Parameter<Q> that)
      Returns the sum of this vector with the parameter specified.
      abstract void setOrigin​(Point o)
      Set the origin point for this vector.
      int size()
      Returns the number of child-elements that make up this geometry element.
      abstract Vector<Q> times​(double k)
      Returns the product of this vector with the specified coefficient (dimensionless).
      abstract Parameter<? extends javax.measure.quantity.Quantity> times​(GeomVector<?> that)
      Returns the dot product (scalar product) of this vector with the one specified.
      abstract Vector<? extends javax.measure.quantity.Quantity> times​(Parameter<?> k)
      Returns the product of this vector with the specified coefficient.
      abstract Vector<? extends javax.measure.quantity.Quantity> timesEBE​(GeomVector<?> that)
      Returns the element-by-element product of this vector with the one specified.
      double[] toArray()
      Returns the values stored in this vector as a Java array, stated in the current units.
      double[] toArray​(double[] array)
      Returns the values stored in this vector, stated in the current units stored in the input Java array.
      abstract GeomVector<Q> toDimension​(int newDim)
      Return a copy of this vector converted to the specified number of physical dimensions.
      abstract Float64Vector toFloat64Vector()
      Returns a Float64Vector containing the elements of this vector stated in the current units.
      abstract ParameterVector<Q> toParameterVector()
      Returns a ParameterVector representation of this vector.
      javolution.text.Text toText()
      Returns the text representation of this geometry element that consists of the name followed by the vector axis values.
      abstract Vector<javax.measure.quantity.Dimensionless> toUnitVector()
      Returns this vector converted to a unit vector by dividing all the vector's elements by the length (norm()) of this vector.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Field Detail

      • X

        public static final int X
        Constant used to identify the X coordinate in a 3D vector.
        See Also:
        Constant Field Values
      • Y

        public static final int Y
        Constant used to identify the Y coordinate in a 3D vector.
        See Also:
        Constant Field Values
      • Z

        public static final int Z
        Constant used to identify the Z coordinate in a 3D vector.
        See Also:
        Constant Field Values
    • Method Detail

      • size

        public int size()
        Returns the number of child-elements that make up this geometry element. This implementation always returns 0 as a vector is not made up of any other elements.
        Specified by:
        size in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The number of child-elements that make up this geometry element.
      • getParDimension

        public int getParDimension()
        Returns the number of parametric dimensions of the geometry element. This implementation always returns 0 as a vector is not parametric.
        Specified by:
        getParDimension in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The number of parametric dimensions of this geometry element.
      • get

        public Parameter<Qget​(int i)
        Returns the value of a Parameter from this vector.
        Parameters:
        i - the dimension index.
        Returns:
        the value of the parameter at i.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i ≥ getPhyDimension())
      • getValue

        public abstract double getValue​(int i)
        Returns the value of the Parameter in this vector as a double, stated in this vector's unit.
        Parameters:
        i - the dimension index.
        Returns:
        the value of the Parameter at i.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i ≥ getPhyDimension())
      • getValue

        public abstract double getValue​(int i,
                                        javax.measure.unit.Unit<Q> unit)
        Returns the value of the Parameter in this vector as a double, stated in the specified units.
        Parameters:
        i - the dimension index.
        unit - the unit to return the value in. May not be null.
        Returns:
        the value of the Parameter at i in the specified unit.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i ≥ getPhyDimension())
      • setOrigin

        public abstract void setOrigin​(Point o)
        Set the origin point for this vector. The origin is used as a reference for drawing the vector and is not a part of the state of this vector and is not used in any calculations with this vector.
        Parameters:
        o - The origin point to assign to this vector. May not be null.
      • getOrigin

        public abstract Point getOrigin()
        Return the origin point for this vector. If no origin has been explicitly set, then the coordinate system origin in the default units is returned.
        Returns:
        The origin point associated with this vector.
      • norm

        public Parameter<Qnorm()
        Returns the Euclidian norm, magnitude, or length of this vector (square root of the dot product of this vector and itself).
        Returns:
        sqrt(this · this).
      • normValue

        public abstract double normValue()
        Returns the norm(), magnitude, or length value of this vector (square root of the dot product of this vector and itself).
        Returns:
        this.norm().doubleValue().
      • mag

        public Parameter<Qmag()
        Returns the Euclidian norm, magnitude, or length of this vector (square root of the dot product of this vector and itself).
        Returns:
        sqrt(this · this).
      • magValue

        public double magValue()
        Returns the norm(), magnitude, or length value of this vector.
        Returns:
        this.norm().doubleValue().
      • opposite

        public abstract Vector<Qopposite()
        Returns the negation of this vector.
        Returns:
        -this.
      • plus

        public abstract Vector<Qplus​(GeomVector<Q> that)
        Returns the sum of this vector with the one specified. The unit of the output vector will be the units of this vector.
        Parameters:
        that - the vector to be added. May not be null.
        Returns:
        this + that.
        Throws:
        DimensionException - if vector dimensions are different.
      • plus

        public abstract Vector<Qplus​(Parameter<Q> that)
        Returns the sum of this vector with the parameter specified. The input parameter is added to each component of this vector. The unit of the output vector will be the units of this vector.
        Parameters:
        that - the parameter to be added to each element of this vector. May not be null.
        Returns:
        this + that.
      • minus

        public abstract Vector<Qminus​(GeomVector<Q> that)
        Returns the difference between this vector and the one specified. The unit of the output vector will be the units of this vector.
        Parameters:
        that - the vector to be subtracted from this vector. May not be null.
        Returns:
        this - that.
        Throws:
        DimensionException - if vector dimensions are different.
      • minus

        public abstract Vector<Qminus​(Parameter<Q> that)
        Subtracts the supplied Parameter from each element of this vector and returns the result. The unit of the output vector will be the units of this vector.
        Parameters:
        that - the Parameter to be subtracted from each element of this vector. May not be null.
        Returns:
        this - that.
      • times

        public abstract Vector<Qtimes​(double k)
        Returns the product of this vector with the specified coefficient (dimensionless).
        Parameters:
        k - the coefficient multiplier.
        Returns:
        this · k
      • times

        public abstract Vector<? extends javax.measure.quantity.Quantity> times​(Parameter<?> k)
        Returns the product of this vector with the specified coefficient.
        Parameters:
        k - the coefficient multiplier. May not be null.
        Returns:
        this · k
      • times

        public abstract Parameter<? extends javax.measure.quantity.Quantity> times​(GeomVector<?> that)
        Returns the dot product (scalar product) of this vector with the one specified.
        Parameters:
        that - the vector multiplier. May not be null.
        Returns:
        this · that
        Throws:
        DimensionException - if this.dimension() != that.dimension()
        See Also:
        Wikipedia: Dot Product
      • dot

        public Parameter<? extends javax.measure.quantity.Quantity> dot​(GeomVector<?> that)
        Returns the dot product (scalar product) of this vector with the one specified.
        Parameters:
        that - the vector multiplier. May not be null.
        Returns:
        this · that
        Throws:
        DimensionException - if this.dimension() != that.dimension()
        See Also:
        Wikipedia: Dot Product
      • timesEBE

        public abstract Vector<? extends javax.measure.quantity.Quantity> timesEBE​(GeomVector<?> that)
        Returns the element-by-element product of this vector with the one specified.
        Parameters:
        that - the vector multiplier. May not be null.
        Returns:
        this .* that
        Throws:
        DimensionException - if this.dimension() != that.dimension()
      • cross

        public abstract Vector<? extends javax.measure.quantity.Quantity> cross​(GeomVector<?> that)
        Returns the cross product of two vectors.
        Parameters:
        that - the vector multiplier. May not be null.
        Returns:
        this x that
        Throws:
        DimensionException - if (that.getDimension() != this.getDimension())
        See Also:
        Wikipedia: Cross Product
      • divide

        public abstract Vector<Qdivide​(double divisor)
        Returns this vector with each element divided by the specified divisor (dimensionless).
        Parameters:
        divisor - the divisor.
        Returns:
        this / divisor.
      • divide

        public abstract Vector<? extends javax.measure.quantity.Quantity> divide​(Parameter<?> that)
        Returns this vector with each element divided by the specified divisor.
        Parameters:
        that - the divisor. May not be null.
        Returns:
        this / that.
      • angle

        public Parameter<javax.measure.quantity.Angle> angle​(GeomVector<?> that)
        Returns the angle between this vector and the specified vector.
        Parameters:
        that - the vector to which the angle will be determined. May not be null.
        Returns:
        acos(this · that)/(norm(this)*norm(that))
      • immutable

        public abstract Vector<Qimmutable()
        Return an immutable version of this vector.
        Returns:
        An immutable version of this vector.
      • isValid

        public boolean isValid()
        Return true if this GeomVector contains valid and finite numerical components. A value of false will be returned if any of the elements in this vector, including the origin, are invalid.
        Specified by:
        isValid in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        true if this geometry element contains valid and finite data.
      • toUnitVector

        public abstract Vector<javax.measure.quantity.Dimensionless> toUnitVector()
        Returns this vector converted to a unit vector by dividing all the vector's elements by the length (norm()) of this vector.
        Returns:
        This vector converted to a unit vector by dividing all the vector's elements by the length of this vector.
      • getBoundsMin

        public Point getBoundsMin()
        Return the coordinate point representing the minimum bounding box corner (e.g.: min X, min Y, min Z).
        Specified by:
        getBoundsMin in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The minimum bounding box coordinate for this geometry element.
      • getBoundsMax

        public Point getBoundsMax()
        Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).
        Specified by:
        getBoundsMax in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The maximum bounding box coordinate for this geometry element.
      • getLimitPoint

        public Point getLimitPoint​(int dim,
                                   boolean max,
                                   double tol)
        Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this geometry element. This implementation simply returns getBoundsMin or getBoundsMax depending on the setting of the "max" flag.
        Specified by:
        getLimitPoint in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Parameters:
        dim - An index indicating the dimension to find the min/max point for (0=X, 1=Y, 2=Z, etc).
        max - Set to true to return the maximum value, false to return the minimum.
        tol - Fractional tolerance to refine the min/max point position to if necessary.
        Returns:
        The point found on this element that is the min or max in the specified coordinate direction.
        See Also:
        getBoundsMin(), getBoundsMax()
      • toParameterVector

        public abstract ParameterVector<QtoParameterVector()
        Returns a ParameterVector representation of this vector.
        Returns:
        A ParameterVector that is equivalent to this vector.
      • toFloat64Vector

        public abstract Float64Vector toFloat64Vector()
        Returns a Float64Vector containing the elements of this vector stated in the current units.
        Returns:
        A Float64Vector that contains the elements of this vector in the current units.
      • toArray

        public double[] toArray()
        Returns the values stored in this vector as a Java array, stated in the current units.
        Returns:
        A new array with the vector element values copied into it.
      • toArray

        public double[] toArray​(double[] array)
        Returns the values stored in this vector, stated in the current units stored in the input Java array.
        Parameters:
        array - An existing array that has at least as many elements as the physical dimension of this vector.
        Returns:
        A reference to the input array after the vector elements have been copied over to it.
        See Also:
        GeomElement.getPhyDimension()
      • getTransformed

        public VectorTrans<QgetTransformed​(GTransform transform)
        Returns transformed version of this element. The returned object implements GeomTransform and contains this element as a child.
        Specified by:
        getTransformed in interface Transformable<Q extends javax.measure.quantity.Quantity>
        Parameters:
        transform - The transformation to apply to this geometry. May not be null.
        Returns:
        A new triangle that is identical to this one with the specified transformation applied.
        Throws:
        DimensionException - if this point is not 3D.
      • toDimension

        public abstract GeomVector<QtoDimension​(int newDim)
        Return a copy of this vector converted to the specified number of physical dimensions. If the number of dimensions is greater than this element, then zeros are added to the additional dimensions. If the number of dimensions is less than this element, then the extra dimensions are simply dropped (truncated). If the new dimensions are the same as the dimension of this element, then this element is simply returned.
        Specified by:
        toDimension in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Parameters:
        newDim - The dimension of the vector to return.
        Returns:
        A copy of this vector converted to the new dimensions.
      • toText

        public javolution.text.Text toText()
        Returns the text representation of this geometry element that consists of the name followed by the vector axis values. For example:
           {v = {{10 ft, -3 ft, 4.56 ft},o={0 m, 0m, 0m}}}
         
        If there is no name, then the output looks like this:
           {{10 ft, -3 ft, 4.56 ft},o={0 m, 0 m, 0 m}}}
         
        Specified by:
        toText in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Overrides:
        toText in class AbstractGeomElement<GeomVector>
        Returns:
        the text representation of this geometry element.
      • copy

        public abstract GeomVector<Qcopy()
        Returns a copy of this GeomVector instance allocated by the calling thread (possibly on the stack).
        Specified by:
        copy in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        an identical and independent copy of this vector.
      • isApproxEqual

        public boolean isApproxEqual​(GeomVector obj)
        Compares this vector against the specified vector for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance). The origin point is ignored.
        Parameters:
        obj - The vector object to compare with.
        Returns:
        true if this vector is approximately identical to that vector; false otherwise.
      • isApproxEqual

        public boolean isApproxEqual​(GeomVector obj,
                                     Parameter<Q> tol)
        Compares this vector against the specified vector for approximate equality (coordinate values approximately equal to this one to within the numerical roundoff tolerance). The origin point is ignored.
        Parameters:
        obj - The vector object to compare with.
        tol - The amount use to define approximate equality. If null then exact numerical equality is required.
        Returns:
        true if this vector is approximately identical to that vector; false otherwise.