Q
- The Quantity (unit type) associated with this vector's coordinate values.public final class Vector<Q extends Quantity> extends GeomVector<Q> implements javolution.lang.ValueType
Modified by: Joseph A. Huwaldt
X, Y, Z
RESOURCES
Modifier and Type | Method and Description |
---|---|
static Vector[] |
allocateArray(int size)
Allocate a recyclable array that can contain Vector objects using factory methods.
|
Vector<Q> |
copy()
Returns a copy of this Vector instance
allocated by 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 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 Quantity> |
divide(Parameter<?> divisor)
Returns this vector with each element divided by the specified divisor.
|
boolean |
equals(java.lang.Object obj)
Compares this vector against the specified object for strict equality (same values
and same units).
|
Point |
getOrigin()
Return the origin point for this vector.
|
int |
getPhyDimension()
Returns the number of physical dimensions of this vector.
|
Unit |
getUnit()
Returns the unit in which the
values in this vector are stated
in. |
double |
getValue(int i)
Returns the value of the Parameter in this vector as a
double , stated
in this vector's unit . |
double |
getValue(int i,
Unit<Q> unit)
Returns the value of the Parameter in this vector as a
double , stated
in the specified units. |
int |
hashCode()
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 Vector<Dimensionless> |
newInstance(int numDims)
Returns a dimensionless
Vector instance of the specified dimension
with all the coordinate values set to zero. |
static <Q extends Quantity> |
newInstance(int numDims,
Unit<Q> unit)
Returns a
Vector instance of the specified dimension and units with
all the coordinate values set to zero. |
double |
normValue()
Returns the
GeomVector.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 void |
recycle(Vector instance)
Recycles a
Vector instance immediately (on the stack when executing in
a StackContext ). |
static void |
recycleArray(Vector[] arr)
Recycle an array of Vector objects that was created by Vector.allocateArray().
|
void |
setOrigin(Point origin)
Set the origin point for this vector.
|
Vector<Q> |
times(double k)
Returns the product of this vector with the specified coefficient (dimensionless).
|
Parameter<? extends Quantity> |
times(GeomVector<?> that)
Returns the dot product (scalar product) of this vector with the one specified.
|
Vector<? extends Quantity> |
times(Parameter<?> k)
Returns the product of this vector with the specified coefficient.
|
Vector<? extends Quantity> |
timesEBE(GeomVector<?> that)
Returns the element-by-element product of this vector with the one specified.
|
Vector |
to(Unit unit)
Returns the equivalent to this vector but stated in the specified unit.
|
Vector<Q> |
toDimension(int newDim)
Return a copy of this vector converted to the specified number of physical
dimensions.
|
Float64Vector |
toFloat64Vector()
Returns a
Float64Vector containing the elements of this vector stated
in the current units. |
ParameterVector<Q> |
toParameterVector()
Returns a
ParameterVector representation of this vector. |
Vector<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 Vector<Dimensionless> |
valueOf(double... x)
Returns a dimensionless
Vector instance holding the specified
double value or values. |
static Vector<Length> |
valueOf(GeomPoint point)
Returns a
Vector instance holding the specified GeomPoint
values. |
static <Q extends Quantity> |
valueOf(GeomVector<Q> vector)
Returns a
Vector instance containing the specified GeomVector values. |
static <Q extends Quantity> |
valueOf(java.util.List<Parameter<Q>> values)
Returns a
Vector instance containing the specified list of Parameter
values with compatible units. |
static <Q extends Quantity> |
valueOf(Parameter<Q>... values)
Returns a
Vector instance holding the specified Parameter
values. |
static <Q extends Quantity> |
valueOf(Unit<Q> unit,
double... x)
Returns a
Vector instance holding the specified double
value or values stated in the specified units. |
static <Q extends Quantity> |
valueOf(Vector<Float64> vector,
Unit<Q> unit)
Returns a
Vector instance containing the specified vector of Float64 values
stated in the specified units. |
static <Q extends Quantity> |
valueOf(Vector<Parameter<Q>> vector)
Returns a
Vector instance containing the specified vector of Parameter
values with compatible units. |
angle, dot, get, getBoundsMax, getBoundsMin, getLimitPoint, getParDimension, getTransformed, isApproxEqual, isApproxEqual, isValid, mag, magValue, norm, size, toArray, toArray, toText
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString
addChangeListener, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
public static Vector<Dimensionless> newInstance(int numDims)
Vector
instance of the specified dimension
with all the coordinate values set to zero.numDims
- the physical dimension of the vector to create.public static <Q extends Quantity> Vector<Q> newInstance(int numDims, Unit<Q> unit)
Vector
instance of the specified dimension and units with
all the coordinate values set to zero.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.numDims
- the physical dimension of the vector to create.unit
- the unit in which the coordinates are stated. May not be null.public static <Q extends Quantity> Vector<Q> valueOf(GeomVector<Q> vector)
Vector
instance containing the specified GeomVector values.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.vector
- The GeomVector to be placed in a new Vector instance. May not be null.public static Vector<Dimensionless> valueOf(double... x)
Vector
instance holding the specified
double
value or values.x
- the dimensionless coordinate values. May not be null.public static <Q extends Quantity> Vector<Q> valueOf(Unit<Q> unit, double... x)
Vector
instance holding the specified double
value or values stated in the specified units.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.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.public static <Q extends Quantity> Vector<Q> valueOf(Vector<Parameter<Q>> vector)
Vector
instance containing the specified vector of Parameter
values with compatible units. All the values are converted to the same units as the
1st value.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.vector
- the vector of Parameter values stated in the specified unit. May not be null.public static <Q extends Quantity> Vector<Q> valueOf(java.util.List<Parameter<Q>> values)
Vector
instance containing the specified list of Parameter
values with compatible units. All the values are converted to the same units as the
1st value.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.values
- the list of Parameter values stated in the specified unit. May not be
null.public static <Q extends Quantity> Vector<Q> valueOf(Vector<Float64> vector, Unit<Q> unit)
Vector
instance containing the specified vector of Float64 values
stated in the specified units.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.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.public static <Q extends Quantity> Vector<Q> valueOf(Parameter<Q>... values)
Vector
instance holding the specified Parameter
values. All the values are converted to the same units as the first value.Q
- The Quantity (unit type) associated with the new vector's coordinate
values.values
- A list of values to store in the vector. May not be null.public static Vector<Length> valueOf(GeomPoint point)
Vector
instance holding the specified GeomPoint
values.point
- A point who's coordinates are to be stored in the vector (making it a
position vector). May not be null.public int getPhyDimension()
getPhyDimension
in interface GeomElement<GeomVector>
public double getValue(int i)
double
, stated
in this vector's unit
.getValue
in class GeomVector<Q extends Quantity>
i
- the dimension index.i
.java.lang.IndexOutOfBoundsException
- (i < 0) || (i ≥ getPhyDimension())
public double getValue(int i, Unit<Q> unit)
double
, stated
in the specified units.getValue
in class GeomVector<Q extends Quantity>
i
- the dimension index.unit
- the unit to return the value in. May not be null.i
in the specified unit.java.lang.IndexOutOfBoundsException
- (i < 0) || (i ≥ getPhyDimension())
public void setOrigin(Point origin)
setOrigin
in class GeomVector<Q extends Quantity>
origin
- The point to use as the origin of this vector (may not be null).public Point getOrigin()
getOrigin
in class GeomVector<Q extends Quantity>
public double normValue()
GeomVector.norm()
, magnitude, or length value of this vector (square root
of the dot product of this vector and itself).normValue
in class GeomVector<Q extends Quantity>
this.norm().doubleValue()
.public Vector<Q> opposite()
opposite
in class GeomVector<Q extends Quantity>
-this
.public Vector<Q> plus(GeomVector<Q> that)
plus
in class GeomVector<Q extends Quantity>
that
- the vector to be added. May not be null.this + that
.DimensionException
- if vector dimensions are different.public Vector<Q> plus(Parameter<Q> that)
plus
in class GeomVector<Q extends Quantity>
that
- the parameter to be added to each element of this vector. May not be
null.this + that
.public Vector<Q> minus(GeomVector<Q> that)
minus
in class GeomVector<Q extends Quantity>
that
- the vector to be subtracted from this vector. May not be null.this - that
.DimensionException
- if vector dimensions are different.public Vector<Q> minus(Parameter<Q> that)
minus
in class GeomVector<Q extends Quantity>
that
- the Parameter to be subtracted from each element of this vector. May
not be null.this - that
.public Vector<Q> times(double k)
times
in class GeomVector<Q extends Quantity>
k
- the coefficient multiplier.this · k
public Vector<? extends Quantity> times(Parameter<?> k)
times
in class GeomVector<Q extends Quantity>
k
- the coefficient multiplier. May not be null.this · k
public Parameter<? extends Quantity> times(GeomVector<?> that)
times
in class GeomVector<Q extends Quantity>
that
- the vector multiplier. May not be null.this · that
DimensionException
- if this.dimension() != that.dimension()
public Vector<? extends Quantity> timesEBE(GeomVector<?> that)
timesEBE
in class GeomVector<Q extends Quantity>
that
- the vector multiplier. May not be null.this .* that
DimensionException
- if this.dimension() != that.dimension()
public Vector<? extends Quantity> cross(GeomVector<?> that)
cross
in class GeomVector<Q extends Quantity>
that
- the vector multiplier. May not be null.this x that
DimensionException
- if
(that.getDimension() != this.getDimension())
public Vector<Q> divide(double divisor)
divide
in class GeomVector<Q extends Quantity>
divisor
- the divisor.this / divisor
.public Vector<? extends Quantity> divide(Parameter<?> divisor)
divide
in class GeomVector<Q extends Quantity>
divisor
- the divisor. May not be null.this / divisor
.public Vector<Q> immutable()
immutable
in class GeomVector<Q extends Quantity>
public Vector<Dimensionless> toUnitVector()
GeomVector.norm()
) of this vector.toUnitVector
in class GeomVector<Q extends Quantity>
public Unit getUnit()
values
in this vector are stated
in.getUnit
in interface GeomElement<GeomVector>
public Vector to(Unit unit)
to
in interface GeomElement<GeomVector>
unit
- the unit of the vector to be returned. May not be null.ConversionException
- if the the input unit is not compatible with this unit.public Vector<Q> toDimension(int newDim)
toDimension
in interface GeomElement<GeomVector>
toDimension
in class GeomVector<Q extends Quantity>
newDim
- The dimension of the vector to return.public Vector<Q> copy()
allocated
by the calling thread
(possibly on the stack).copy
in interface GeomElement<GeomVector>
copy
in interface javolution.lang.ValueType
copy
in class GeomVector<Q extends Quantity>
public Vector<Q> copyToReal()
copyToReal
in interface GeomElement<GeomVector>
public ParameterVector<Q> toParameterVector()
ParameterVector
representation of this vector.toParameterVector
in class GeomVector<Q extends Quantity>
public Float64Vector toFloat64Vector()
Float64Vector
containing the elements of this vector stated
in the current units.toFloat64Vector
in class GeomVector<Q extends Quantity>
public boolean equals(java.lang.Object obj)
equals
in class AbstractGeomElement<GeomVector>
obj
- the object to compare with.true
if this vector is identical to that vector;
false
otherwise.public int hashCode()
hashCode
in class AbstractGeomElement<GeomVector>
public static void recycle(Vector instance)
Vector
instance immediately (on the stack when executing in
a StackContext
).instance
- The instance to be recycled.public static Vector[] allocateArray(int size)
WARNING: The array returned may not be zeroed. Any object references in the returned array must be assumed to be invalid. Also, the returned array may be larger than the requested size! The array returned by this method can be recycled by recycleArray().
size
- The minimum number of elements for the returned array to contain.recycleArray(geomss.geom.Vector[])
public static void recycleArray(Vector[] arr)
arr
- The array to be recycled. The array must have been created by this the
allocateArray() method!allocateArray(int)