Package geomss.geom

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

    • Method Detail

      • newInstance

        public static <Q extends javax.measure.quantity.Quantity> VectorTrans<Q> newInstance​(GeomVector<Q> child,
                                                                                             GTransform transform)
        Returns a 3D VectorTrans instance holding the specified GeomVector and GTransform.
        Type Parameters:
        Q - The Quantity (unit type) of this vector.
        Parameters:
        child - The vector that is the child of this transform element (may not be null).
        transform - The transform held by this transform element (may not be null).
        Returns:
        the transform element having the specified values.
        Throws:
        DimensionException - if the input element is not 3D.
      • getTransform

        public GTransform getTransform()
        Returns the transformation represented by this transformation element.
        Specified by:
        getTransform in interface GeomTransform<Q extends javax.measure.quantity.Quantity>
        Returns:
        The transformation represented by this transformation element.
      • getTotalTransform

        public GTransform getTotalTransform()
        Returns the total transformation represented by an entire chain of GeomTransform objects below this one.
        Specified by:
        getTotalTransform in interface GeomTransform<Q extends javax.measure.quantity.Quantity>
        Returns:
        The total transformation represented by an entire chain of GeomTransform objects below this one.
      • setTransform

        public void setTransform​(GTransform transform)
        Sets the transformation represented by this transformation element.
        Specified by:
        setTransform in interface GeomTransform<Q extends javax.measure.quantity.Quantity>
        Parameters:
        transform - The transform to set this transform element to (may not be null).
      • getChild

        public GeomVector<QgetChild()
        Returns the child object transformed by this transform element.
        Specified by:
        getChild in interface GeomTransform<Q extends javax.measure.quantity.Quantity>
        Returns:
        The child object transformed by this transform element.
      • copyToReal

        public Vector<QcopyToReal()
        Return a copy of the child object transformed by this transformation.
        Specified by:
        copyToReal in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Specified by:
        copyToReal in interface GeomTransform<Q extends javax.measure.quantity.Quantity>
        Returns:
        A copy of the child object transformed by this transformation.
      • recycle

        public static void recycle​(VectorTrans instance)
        Recycles a VectorTrans instance immediately (on the stack when executing in a StackContext).
        Parameters:
        instance - The instance to be recycled.
      • getPhyDimension

        public int getPhyDimension()
        Returns the number of physical dimensions of the geometry element. This implementation always returns 3.
        Specified by:
        getPhyDimension in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The number of physical dimensions of this geometry element.
      • getValue

        public double getValue​(int i)
        Returns the value of the Parameter in this vector as a double, stated in this vector's unit.
        Specified by:
        getValue in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        i - the dimension index.
        Returns:
        the value of the Parameter at i.
        Throws:
        java.lang.IndexOutOfBoundsException - (i < 0) || (i ≥ getPhyDimension())
      • getValue

        public 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.
        Specified by:
        getValue in class GeomVector<Q extends javax.measure.quantity.Quantity>
        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 void setOrigin​(Point origin)
        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.
        Specified by:
        setOrigin in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        origin - The new origin point for the vector. May not be null.
      • getOrigin

        public Point getOrigin()
        Return the origin point for this vector. If no origin has been explicitly set, then the coordinate system origin is returned.
        Specified by:
        getOrigin in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        The origin point for this vector.
      • normValue

        public double normValue()
        Returns the GeomVector.norm(), magnitude, or length value of the vector from the origin to this point (square root of the dot product of the origin-to-this-point vector and itself).
        Specified by:
        normValue in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        this.norm().doubleValue().
      • opposite

        public Vector<Qopposite()
        Returns the negation of this vector.
        Specified by:
        opposite in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        -this.
      • plus

        public 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.
        Specified by:
        plus in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        that - the vector to be added. May not be null.
        Returns:
        this + that.
        Throws:
        DimensionException - if vector dimensions are different.
      • plus

        public 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.
        Specified by:
        plus in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        that - the parameter to be added to each element of this vector. May not be null.
        Returns:
        this + that.
      • minus

        public 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.
        Specified by:
        minus in class GeomVector<Q extends javax.measure.quantity.Quantity>
        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 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.
        Specified by:
        minus in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        that - the Parameter to be subtracted from each element of this vector. May not be null.
        Returns:
        this - that.
      • times

        public Vector<Qtimes​(double k)
        Returns the product of this vector with the specified coefficient (dimensionless).
        Specified by:
        times in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        k - the coefficient multiplier.
        Returns:
        this · k
      • times

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

        public Parameter<? extends javax.measure.quantity.Quantity> times​(GeomVector<?> that)
        Returns the dot product (scalar product) of this vector with the one specified.
        Specified by:
        times in class GeomVector<Q extends javax.measure.quantity.Quantity>
        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 Vector<? extends javax.measure.quantity.Quantity> timesEBE​(GeomVector<?> that)
        Returns the element-by-element product of this vector with the one specified.
        Specified by:
        timesEBE in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        that - the vector multiplier. May not be null.
        Returns:
        this .* that
        Throws:
        DimensionException - if this.dimension() != that.dimension()
      • cross

        public Vector<? extends javax.measure.quantity.Quantity> cross​(GeomVector<?> that)
        Returns the cross product of two vectors.
        Specified by:
        cross in class GeomVector<Q extends javax.measure.quantity.Quantity>
        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 Vector<Qdivide​(double divisor)
        Returns this vector with each element divided by the specified divisor (dimensionless).
        Specified by:
        divide in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        divisor - the divisor.
        Returns:
        this / divisor.
      • divide

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

        public Vector<Qimmutable()
        Return an immutable version of this vector.
        Specified by:
        immutable in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        An immutable version of this vector.
      • toUnitVector

        public Vector<javax.measure.quantity.Dimensionless> toUnitVector()
        Returns this vector converted to a unit vector by dividing all the vector's elements by the length (GeomVector.norm()) of this vector.
        Specified by:
        toUnitVector in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        This vector converted to a unit vector.
      • getUnit

        public javax.measure.unit.Unit getUnit()
        Returns the unit in which the values in this vector are stated in.
        Specified by:
        getUnit in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Returns:
        The unit in which the geometry in this element are stated.
      • to

        public GeomVector to​(javax.measure.unit.Unit unit)
                      throws javax.measure.converter.ConversionException
        Returns the equivalent to this vector but stated in the specified unit.
        Specified by:
        to in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Parameters:
        unit - the unit of the vector to be returned. May not be null.
        Returns:
        an equivalent to this vector but stated in the specified unit.
        Throws:
        javax.measure.converter.ConversionException - if the the input unit is not compatible with this unit.
      • toFloat64Vector

        public Float64Vector toFloat64Vector()
        Returns a Float64Vector containing the elements of this vector stated in the current units.
        Specified by:
        toFloat64Vector in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Returns:
        A Float64Vector that contains the elements of this vector in the current units.
      • 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>
        Overrides:
        getTransformed in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        transform - The transform to apply to this vector. May not be null.
        Returns:
        A new triangle that is identical to this one with the specified transformation applied.
      • toDimension

        public VectorTrans<QtoDimension​(int newDim)
        Return the equivalent of this vector converted to the specified number of physical dimensions. This implementation will throw an exception if the specified dimension is anything other than 3.
        Specified by:
        toDimension in interface GeomElement<Q extends javax.measure.quantity.Quantity>
        Specified by:
        toDimension in class GeomVector<Q extends javax.measure.quantity.Quantity>
        Parameters:
        newDim - The dimension of the vector to return. MUST equal 3.
        Returns:
        The equivalent of this vector converted to the new dimensions.
        Throws:
        java.lang.IllegalArgumentException - if the new dimension is anything other than 3.
      • equals

        public boolean equals​(java.lang.Object obj)
        Compares this VectorTrans against the specified object for strict equality (same values and same units).
        Overrides:
        equals in class AbstractGeomElement<GeomVector>
        Parameters:
        obj - the object to compare with.
        Returns:
        true if this point is identical to that point; false otherwise.
      • copy

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