Package jahuwaldt.js.param
Class AbstractParamVector<Q extends javax.measure.quantity.Quantity,T extends AbstractParamVector<Q,T>>
- java.lang.Object
-
- org.jscience.mathematics.vector.Vector<Parameter<Q>>
-
- jahuwaldt.js.param.AbstractParamVector<Q,T>
-
- Type Parameters:
Q
- The Quantity (unit type, such as Length or Volume) of this parameter.T
- The type of AbstractParamVector.
- All Implemented Interfaces:
java.lang.Comparable<javax.measure.Measurable<Q>>
,javax.measure.Measurable<Q>
,javolution.lang.Immutable
,javolution.lang.Realtime
,javolution.lang.ValueType
,GroupAdditive<Vector<Parameter<Q>>>
,Structure<Vector<Parameter<Q>>>
,VectorSpace<Vector<Parameter<Q>>,Parameter<Q>>
,VectorSpaceNormed<Vector<Parameter<Q>>,Parameter<Q>>
- Direct Known Subclasses:
Coordinate3D
,ParameterVector
public abstract class AbstractParamVector<Q extends javax.measure.quantity.Quantity,T extends AbstractParamVector<Q,T>> extends Vector<Parameter<Q>> implements VectorSpaceNormed<Vector<Parameter<Q>>,Parameter<Q>>, javax.measure.Measurable<Q>, javolution.lang.Realtime
- Version:
- October 31, 2015
- Author:
- Joseph A. Huwaldt, Date: November 21, 2008
-
-
Constructor Summary
Constructors Constructor Description AbstractParamVector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Parameter<javax.measure.quantity.Angle>
angle(AbstractParamVector that)
Returns the angle between this vector and the specified vector.int
compareTo(javax.measure.Measurable<Q> that)
Compares thenorm()
of this measure with the specified measurable object.T
divide(double divisor)
Returns this vector with each element divided by the specified divisor (dimensionless).Parameter<?>
dot(Vector that)
Returns the dot product of this vector with the one specified.double
doubleValue(javax.measure.unit.Unit<Q> unit)
Returns the value of this measurable stated in the specified unit as adouble
.abstract T
fromVector3D(Vector3D<Q> vector)
Return the specifiedVector3D
object as a vector of a particular subtype of this class.abstract javax.measure.unit.Unit<Q>
getUnit()
Returns the unit in which the values in this vector are stated.double
getValue(int i)
Returns the value of the Parameter in this vector as adouble
in the current units of the specified dimension of this vector.long
longValue(javax.measure.unit.Unit<Q> unit)
Returns the estimated integral value of this measurable stated in the specified unit as along
.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 thenorm()
, magnitude, or length value of this vector.abstract T
minus(Parameter<Q> that)
Subtracts the supplied Parameter from this vector.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 thenorm()
, magnitude, or length value of this vector.abstract T
plus(Parameter<Q> that)
Returns the sum of this vector with the parameter specified.abstract T
times(double k)
Returns the product of this vector with the specified coefficient.abstract <R extends javax.measure.quantity.Quantity>
AbstractParamVector<R,? extends AbstractParamVector>to(javax.measure.unit.Unit<R> unit)
Returns the equivalent to this vector but stated in the specified unit.double[]
toArray()
Returns a new Java array that contains the values of the coordinates of this vector in the current units.double[]
toArray(double[] array)
Fills the input Java array with the values of the coordinates of this vector in the current units.abstract Vector3D<Q>
toVector3D()
Returns a Vector3D representation of this vector if possible.-
Methods inherited from class org.jscience.mathematics.vector.Vector
copy, cross, equals, equals, get, getDimension, hashCode, minus, opposite, plus, times, times, toString, toText
-
Methods inherited from interface org.jscience.mathematics.structure.GroupAdditive
opposite, plus
-
Methods inherited from interface org.jscience.mathematics.structure.VectorSpace
times
-
-
-
-
Constructor Detail
-
AbstractParamVector
public AbstractParamVector()
-
-
Method Detail
-
toVector3D
public abstract Vector3D<Q> toVector3D()
Returns a Vector3D representation of this vector if possible.- Returns:
- A Vector3D that is equivalent to this vector
- Throws:
DimensionException
- if this vector has any number of dimensions other than 3.
-
fromVector3D
public abstract T fromVector3D(Vector3D<Q> vector) throws javax.measure.converter.ConversionException
Return the specifiedVector3D
object as a vector of a particular subtype of this class.- Parameters:
vector
- TheVector3D
object to be converted to a specific subtype of this class.- Returns:
- An instance of a specific subtype of this class that is equivalent to the
supplied
Vector3D
object. - Throws:
javax.measure.converter.ConversionException
- if the sub-type can not represent the units used in the supplied vector.
-
getValue
public double getValue(int i)
Returns the value of the Parameter in this vector as adouble
in the current units of the specified dimension of this vector.- Parameters:
i
- the dimension index.- Returns:
- the value of the Parameter at
i
. - Throws:
java.lang.IndexOutOfBoundsException
-(i < 0) || (i > dimension()-1)
-
norm
public Parameter<Q> norm()
Returns the Euclidian norm, magnitude, or length of this vector (square root of the dot product of this vector and itself).- Specified by:
norm
in interfaceVectorSpaceNormed<Q extends javax.measure.quantity.Quantity,T extends AbstractParamVector<Q,T>>
- Returns:
sqrt(this · this)
.- See Also:
- Wikipedia: Vector Norm
-
normValue
public abstract double normValue()
Returns thenorm()
, magnitude, or length value of this vector.- Returns:
this.norm().getValue()
.
-
mag
public Parameter<Q> mag()
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 thenorm()
, magnitude, or length value of this vector.- Returns:
this.norm().doubleValue()
.
-
plus
public abstract T plus(Parameter<Q> that)
Returns the sum of this vector with the parameter specified. The unit of the output vector will be the units of this vector.- Parameters:
that
- the parameter to be added to this vector.- Returns:
this + that
.
-
minus
public abstract T minus(Parameter<Q> that)
Subtracts the supplied Parameter from this vector. The unit of the output vector will be the units of this vector.- Parameters:
that
- the Parameter to be subtracted from this vector.- Returns:
this - that
.
-
times
public abstract T times(double k)
Returns the product of this vector with the specified coefficient.- Parameters:
k
- the coefficient multiplier.- Returns:
this · k
-
dot
public Parameter<?> dot(Vector that)
Returns the dot product of this vector with the one specified.- Parameters:
that
- the vector multiplier.- Returns:
this · that
- Throws:
DimensionException
- ifthis.dimension() != that.dimension()
- See Also:
- Wikipedia: Dot Product
-
divide
public T divide(double divisor)
Returns this vector with each element divided by the specified divisor (dimensionless).- Parameters:
divisor
- the divisor.- Returns:
this / divisor
.
-
angle
public Parameter<javax.measure.quantity.Angle> angle(AbstractParamVector that)
Returns the angle between this vector and the specified vector.- Parameters:
that
- the vector to which the angle will be determined.- Returns:
acos(this · that)/(norm(this)*norm(that))
-
getUnit
public abstract javax.measure.unit.Unit<Q> getUnit()
Returns the unit in which the values in this vector are stated.- Returns:
- The unit in which the values in this vector are stated
-
to
public abstract <R extends javax.measure.quantity.Quantity> AbstractParamVector<R,? extends AbstractParamVector> to(javax.measure.unit.Unit<R> unit)
Returns the equivalent to this vector but stated in the specified unit.- Type Parameters:
R
- The Quantity (unit type) of the vector being output.- Parameters:
unit
- the unit of the vector to be returned.- Returns:
- a vector equivalent to this vector but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the current model does not allows for conversion to the specified unit.
-
doubleValue
public double doubleValue(javax.measure.unit.Unit<Q> unit)
Returns the value of this measurable stated in the specified unit as adouble
. This implementation returns thenormValue()
stated in the specified units.- Specified by:
doubleValue
in interfacejavax.measure.Measurable<Q extends javax.measure.quantity.Quantity>
- Parameters:
unit
- the unit in which this measurable value is stated.- Returns:
- the numeric value after conversion to type
double
.
-
longValue
public final long longValue(javax.measure.unit.Unit<Q> unit)
Returns the estimated integral value of this measurable stated in the specified unit as along
. This implementation returns thenormValue()
stated in the specified units.Note: This method differs from the
Number.longValue()
in the sense that the closest integer value is returned and an ArithmeticException is raised instead of a bit truncation in case of overflow (safety critical).- Specified by:
longValue
in interfacejavax.measure.Measurable<Q extends javax.measure.quantity.Quantity>
- Parameters:
unit
- the unit in which the measurable value is stated.- Returns:
- the numeric value after conversion to type
long
. - Throws:
java.lang.ArithmeticException
- if this quantity cannot be represented as along
number in the specified unit.
-
compareTo
public int compareTo(javax.measure.Measurable<Q> that)
Compares thenorm()
of this measure with the specified measurable object.- Specified by:
compareTo
in interfacejava.lang.Comparable<Q extends javax.measure.quantity.Quantity>
- Parameters:
that
- the measure to compare with.- Returns:
- a negative integer, zero, or a positive integer as this measure is less than, equal to, or greater than that measurable.
- Throws:
javax.measure.converter.ConversionException
- if the current model does not allows for these measure to be compared.
-
toArray
public double[] toArray(double[] array)
Fills the input Java array with the values of the coordinates of this vector in the current units.- Parameters:
array
- An existing array of at least this.getDimension() size that will be filled with the values from this vector.- Returns:
- The input Java array filled with the coordinate values from this vector.
-
toArray
public double[] toArray()
Returns a new Java array that contains the values of the coordinates of this vector in the current units.- Returns:
- A new Java array of values from this vector.
-
-