Package geomss.geom
Class MutableVector<Q extends javax.measure.quantity.Quantity>
- java.lang.Object
 - 
- geomss.geom.AbstractGeomElement<GeomVector>
 - 
- geomss.geom.GeomVector<Q>
 - 
- geomss.geom.MutableVector<Q>
 
 
 
 
- 
- Type Parameters:
 Q- The Quantity (unit type) of the elements of this vector.
- All Implemented Interfaces:
 GeomElement<GeomVector>,Transformable<GeomVector>,java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,javolution.lang.Reusable,javolution.xml.XMLSerializable
public final class MutableVector<Q extends javax.measure.quantity.Quantity> extends GeomVector<Q>
A container that holds changeable coordinates of an n-dimensional vector which indicates direction, but not position.Modified by: Joseph A. Huwaldt
- Version:
 - November 27, 2015
 - Author:
 - Joseph A. Huwaldt, Date: June 13, 2009
 - See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
- 
Fields inherited from class geomss.geom.GeomVector
X, Y, Z 
- 
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES 
 - 
 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableVector<Q>copy()Returns a copy of this Vector instanceallocatedby the calling thread (possibly on the stack).Vector<Q>copyToReal()Return a copy of this object with any transformations or subranges removed (applied).Vector<? extends javax.measure.quantity.Quantity>cross(GeomVector<?> that)Returns the cross product of two vectors.Vector<Q>divide(double divisor)Returns this vector with each element divided by the specified divisor (dimensionless).Vector<? extends javax.measure.quantity.Quantity>divide(Parameter<?> divisor)Returns this vector with each element divided by the specified divisor.booleanequals(java.lang.Object obj)Compares this vector against the specified object for strict equality (same values and same units).PointgetOrigin()Return the origin point for this vector.intgetPhyDimension()Returns the number of physical dimensions of this vector.javax.measure.unit.UnitgetUnit()Returns the unit in which thevaluesin this vector are stated in.doublegetValue(int i)Returns the value of the Parameter in this vector as adouble, stated in this vector'sunit.doublegetValue(int i, javax.measure.unit.Unit<Q> unit)Returns the value of the Parameter in this vector as adouble, stated in the specified units.inthashCode()Returns the hash code for this parameter.Vector<Q>immutable()Return an immutable version of this vector.Vector<Q>minus(GeomVector<Q> that)Returns the difference between this vector and the one specified.Vector<Q>minus(Parameter<Q> that)Subtracts the supplied Parameter from each element of this vector and returns the result.static MutableVector<javax.measure.quantity.Dimensionless>newInstance(int dim)Returns a dimensionlessMutableVectorinstance of the specified dimension with all the coordinate values set to zero.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>newInstance(int dim, javax.measure.unit.Unit<Q> unit)Returns aMutableVectorinstance of the specified dimension and units with all the coordinate values set to zero.doublenormValue()Returns theGeomVector.norm(), magnitude, or length value of this vector (square root of the dot product of this vector and itself).Vector<Q>opposite()Returns the negation of this vector.Vector<Q>plus(GeomVector<Q> that)Returns the sum of this vector with the one specified.Vector<Q>plus(Parameter<Q> that)Returns the sum of this vector with the parameter specified.static voidrecycle(MutableVector instance)Recycles aMutableVectorinstance immediately (on the stack when executing in aStackContext).voidset(int i, Parameter<Q> value)Set the value of a vector dimension to the specified Parameter.voidset(GeomVector<Q> v)Set the value of elements of this vector to the elements of the specified vector.voidsetOrigin(Point origin)Set the origin point for this vector.voidsetValue(int i, double value)Set the value of a vector dimension to the specified double in the current vector units.Vector<Q>times(double k)Returns the product of this vector with the specified coefficient (dimensionless).Parameter<? extends javax.measure.quantity.Quantity>times(GeomVector<?> that)Returns the dot product (scalar product) of this vector with the one specified.Vector<? extends javax.measure.quantity.Quantity>times(Parameter<?> k)Returns the product of this vector with the specified coefficient.Vector<? extends javax.measure.quantity.Quantity>timesEBE(GeomVector<?> that)Returns the element-by-element product of this vector with the one specified.MutableVectorto(javax.measure.unit.Unit unit)Returns the equivalent to this vector but stated in the specified unit.MutableVector<Q>toDimension(int newDim)Return a copy of this vector converted to the specified number of physical dimensions.Float64VectortoFloat64Vector()Returns aFloat64Vectorcontaining the elements of this vector stated in the current units.ParameterVector<Q>toParameterVector()Returns aParameterVectorrepresentation of this vector.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.static MutableVector<javax.measure.quantity.Dimensionless>valueOf(double... x)Returns a dimensionlessMutableVectorinstance holding the specifieddoublevalue or values.static MutableVector<javax.measure.quantity.Length>valueOf(GeomPoint point)Returns aMutableVectorinstance holding the specifiedGeomPointvalues.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(GeomVector<Q> vector)Returns aVectorinstance containing the specified GeomVector values.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(Parameter<Q>... values)Returns aMutableVectorinstance holding the specifiedParametervalues.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(java.util.List<Parameter<Q>> values)Returns aMutableVectorinstance containing the specified list of Parameter values with compatible units.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(javax.measure.unit.Unit<Q> unit, double... x)Returns aMutableVectorinstance holding the specifieddoublevalue or values stated in the specified units.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(Vector<Parameter<Q>> vector)Returns aMutableVectorinstance containing the specified vector of Parameter values with compatible units.static <Q extends javax.measure.quantity.Quantity>
MutableVector<Q>valueOf(Vector<Float64> vector, javax.measure.unit.Unit<Q> unit)Returns aMutableVectorinstance containing the specified vector of Float64 values stated in the specified units.- 
Methods inherited from class geomss.geom.GeomVector
angle, dot, get, getBoundsMax, getBoundsMin, getLimitPoint, getParDimension, getTransformed, isApproxEqual, isApproxEqual, isValid, mag, magValue, norm, size, toArray, toArray, toText 
- 
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString 
- 
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName 
 - 
 
 - 
 
- 
- 
Method Detail
- 
newInstance
public static MutableVector<javax.measure.quantity.Dimensionless> newInstance(int dim)
Returns a dimensionlessMutableVectorinstance of the specified dimension with all the coordinate values set to zero.- Parameters:
 dim- the physical dimension of the vector to create.- Returns:
 - the vector having the specified dimension and zero meters for values.
 
 
- 
newInstance
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> newInstance(int dim, javax.measure.unit.Unit<Q> unit)
Returns aMutableVectorinstance of the specified dimension and units with all the coordinate values set to zero.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 dim- the physical dimension of the vector to create.unit- the unit in which the coordinates are stated. May not be null.- Returns:
 - the vector having the specified dimension and zero meters for values.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(GeomVector<Q> vector)
Returns aVectorinstance containing the specified GeomVector values.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 vector- the GeomVector to be placed in a new Vector instance. May not be null.- Returns:
 - the vector having the specified values.
 
 
- 
valueOf
public static MutableVector<javax.measure.quantity.Dimensionless> valueOf(double... x)
Returns a dimensionlessMutableVectorinstance holding the specifieddoublevalue or values.- Parameters:
 x- The dimensionless coordinate values. May not be null.- Returns:
 - the vector having the specified value.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(javax.measure.unit.Unit<Q> unit, double... x)
Returns aMutableVectorinstance holding the specifieddoublevalue or values stated in the specified units.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 unit- the unit in which the coordinates are stated. May not be null.x- the coordinate values stated in the specified unit. May not be null.- Returns:
 - the vector having the specified value.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(Vector<Parameter<Q>> vector)
Returns aMutableVectorinstance containing the specified vector of Parameter values with compatible units. All the values are converted to the same units as the 1st value.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 vector- the vector of Parameter values stated in the specified unit. May not be null.- Returns:
 - the vector having the specified values.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(java.util.List<Parameter<Q>> values)
Returns aMutableVectorinstance containing the specified list of Parameter values with compatible units. All the values are converted to the same units as the 1st value.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 values- the list of Parameter values stated in the specified unit. May not be null.- Returns:
 - the vector having the specified values.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(Vector<Float64> vector, javax.measure.unit.Unit<Q> unit)
Returns aMutableVectorinstance containing the specified vector of Float64 values stated in the specified units.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 vector- the vector of Float64 values stated in the specified unit. May not be null.unit- the unit in which the coordinates are stated. May not be null.- Returns:
 - the vector having the specified values.
 
 
- 
valueOf
public static <Q extends javax.measure.quantity.Quantity> MutableVector<Q> valueOf(Parameter<Q>... values)
Returns aMutableVectorinstance holding the specifiedParametervalues. All the values are converted to the same units as the first value.- Type Parameters:
 Q- The Quantity (unit type) of the returned vector.- Parameters:
 values- A list of values to store in the vector. May not be null.- Returns:
 - the vector having the specified values in the units of x.
 
 
- 
valueOf
public static MutableVector<javax.measure.quantity.Length> valueOf(GeomPoint point)
Returns aMutableVectorinstance holding the specifiedGeomPointvalues.- Parameters:
 point- A point who's coordinates are to be stored in the vector (making it a position vector). May not be null.- Returns:
 - the vector having the specified point coordinate values in it.
 
 
- 
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of this vector.- Returns:
 - The number of physical dimensions of this vector.
 
 
- 
set
public void set(int i, Parameter<Q> value)
Set the value of a vector dimension to the specified Parameter.- Parameters:
 i- the dimension index.value- The new value of the parameter to set ati. May not be null.- Throws:
 java.lang.IndexOutOfBoundsException-(i < 0) || (i ≥ getPhyDimension())
 
- 
set
public void set(GeomVector<Q> v)
Set the value of elements of this vector to the elements of the specified vector.- Parameters:
 v- The new vector to make this vector equal to. May not be null.- Throws:
 DimensionException-(v.getPhyDimension() != getPhyDimension())
 
- 
setValue
public void setValue(int i, double value)
Set the value of a vector dimension to the specified double in the current vector units.- Parameters:
 i- the dimension index.value- The new value of the parameter to set atiin the current units of this vector.- Throws:
 java.lang.IndexOutOfBoundsException-(i < 0) || (i ≥ getPhyDimension())
 
- 
getValue
public double getValue(int i)
Returns the value of the Parameter in this vector as adouble, stated in this vector'sunit.- Specified by:
 getValuein classGeomVector<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 adouble, stated in the specified units.- Specified by:
 getValuein classGeomVector<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 
iin 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:
 setOriginin classGeomVector<Q extends javax.measure.quantity.Quantity>- Parameters:
 origin- The point to set as the origin of this vector. May not be null.
 
- 
getOrigin
public Point getOrigin()
Return the origin point for this vector.- Specified by:
 getOriginin classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 - The origin point for this vector.
 
 
- 
normValue
public double normValue()
Returns theGeomVector.norm(), magnitude, or length value of this vector (square root of the dot product of this vector and itself).- Specified by:
 normValuein classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 this.norm().getValue().
 
- 
opposite
public Vector<Q> opposite()
Returns the negation of this vector.- Specified by:
 oppositein classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 -this.
 
- 
plus
public Vector<Q> plus(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:
 plusin classGeomVector<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<Q> plus(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:
 plusin classGeomVector<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<Q> minus(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:
 minusin classGeomVector<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<Q> minus(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:
 minusin classGeomVector<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<Q> times(double k)
Returns the product of this vector with the specified coefficient (dimensionless).- Specified by:
 timesin classGeomVector<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:
 timesin classGeomVector<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:
 timesin classGeomVector<Q extends javax.measure.quantity.Quantity>- Parameters:
 that- the vector multiplier. May not be null.- Returns:
 this · that- Throws:
 DimensionException- ifthis.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:
 timesEBEin classGeomVector<Q extends javax.measure.quantity.Quantity>- Parameters:
 that- the vector multiplier. May not be null.- Returns:
 this .* that- Throws:
 DimensionException- ifthis.dimension() != that.dimension()
 
- 
cross
public Vector<? extends javax.measure.quantity.Quantity> cross(GeomVector<?> that)
Returns the cross product of two vectors.- Specified by:
 crossin classGeomVector<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<Q> divide(double divisor)
Returns this vector with each element divided by the specified divisor (dimensionless).- Specified by:
 dividein classGeomVector<Q extends javax.measure.quantity.Quantity>- Parameters:
 divisor- the divisor.- Returns:
 this / divisor.
 
- 
divide
public Vector<? extends javax.measure.quantity.Quantity> divide(Parameter<?> divisor)
Returns this vector with each element divided by the specified divisor.- Specified by:
 dividein classGeomVector<Q extends javax.measure.quantity.Quantity>- Parameters:
 divisor- the divisor. May not be null.- Returns:
 this / divisor.
 
- 
immutable
public Vector<Q> immutable()
Return an immutable version of this vector.- Specified by:
 immutablein classGeomVector<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:
 toUnitVectorin classGeomVector<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 thevaluesin this vector are stated in.- Returns:
 - The unit in which the values in this vector are stated.
 
 
- 
to
public MutableVector to(javax.measure.unit.Unit unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this vector but stated in the specified unit.- 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.
 
- 
toDimension
public MutableVector<Q> toDimension(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:
 toDimensionin interfaceGeomElement<Q extends javax.measure.quantity.Quantity>- Specified by:
 toDimensionin classGeomVector<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.
 
 
- 
copy
public MutableVector<Q> copy()
Returns a copy of this Vector instanceallocatedby the calling thread (possibly on the stack).- Specified by:
 copyin interfaceGeomElement<Q extends javax.measure.quantity.Quantity>- Specified by:
 copyin classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 - an identical and independent copy of this vector.
 
 
- 
copyToReal
public Vector<Q> copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Returns:
 - A copy of this object with any transformations or subranges removed.
 
 
- 
toParameterVector
public ParameterVector<Q> toParameterVector()
Returns aParameterVectorrepresentation of this vector.- Specified by:
 toParameterVectorin classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 - A ParameterVector that is equivalent to this vector.
 
 
- 
toFloat64Vector
public Float64Vector toFloat64Vector()
Returns aFloat64Vectorcontaining the elements of this vector stated in the current units.- Specified by:
 toFloat64Vectorin classGeomVector<Q extends javax.measure.quantity.Quantity>- Returns:
 - A Float64Vector that contains the elements of this vector in the current units.
 
 
- 
equals
public boolean equals(java.lang.Object obj)
Compares this vector against the specified object for strict equality (same values and same units).- Overrides:
 equalsin classAbstractGeomElement<GeomVector>- Parameters:
 obj- the object to compare with.- Returns:
 trueif this vector is identical to that vector;falseotherwise.
 
- 
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
 hashCodein classAbstractGeomElement<GeomVector>- Returns:
 - the hash code value.
 
 
- 
recycle
public static void recycle(MutableVector instance)
Recycles aMutableVectorinstance immediately (on the stack when executing in aStackContext).- Parameters:
 instance- The instance to be recycled.
 
 - 
 
 -