V
- Vector implementation typepublic abstract class EuclideanVector<V extends EuclideanVector<V>> extends Object implements Vector<V>, Point<V>
here
for a discussion
of the combination of point and vector functionality into a single
class hierarchy.Constructor and Description |
---|
EuclideanVector() |
Modifier and Type | Method and Description |
---|---|
abstract V |
directionTo(V v)
Return the unit vector representing the direction of displacement from this
vector to the given vector.
|
abstract boolean |
eq(V v,
Precision.DoubleEquivalence precision)
Return true if the current instance and given vector are considered equal as evaluated by the
given precision context.
|
protected double |
getCheckedNorm()
Return the vector norm value, throwing an
IllegalArgumentException if the value is not real
(ie, NaN or infinite) or zero. |
boolean |
isZero(Precision.DoubleEquivalence precision)
Return true if the current instance is considered equal to the zero vector as evaluated by the
given precision context.
|
abstract V |
lerp(V v,
double t)
Get a vector constructed by linearly interpolating between this vector and the given vector.
|
abstract V |
vectorTo(V v)
Return the vector representing the displacement from this vector
to the given vector.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, add, angle, distance, distanceSq, dot, getZero, multiply, negate, norm, normalize, normalizeOrNull, normSq, subtract, subtract, withNorm
getDimension, isFinite, isInfinite, isNaN
public EuclideanVector()
public abstract V vectorTo(V v)
v.subtract(thisVector)
but with a method name that is much easier to visualize.v
- the vector that the returned vector will be directed towardpublic abstract V directionTo(V v)
v.subtract(thisVector).normalize()
but without the intermediate vector instance.v
- the vector that the returned vector will be directed towardIllegalArgumentException
- if the norm of the vector pointing
from this instance to v
is zero, NaN, or infinitepublic abstract V lerp(V v, double t)
V = (1 - t)*A + t*B
, where A
is the current vector and B
is the given vector. This means that if t = 0
, a
vector equal to the current vector will be returned. If t = 1
, a vector equal to the
argument will be returned. The t
parameter is not constrained to the range [0, 1]
,
meaning that linear extrapolation can also be performed with this method.v
- other vectort
- interpolation parameterpublic abstract boolean eq(V v, Precision.DoubleEquivalence precision)
Equality is determined by comparing each pair of components in turn from the two
vectors. If all components evaluate as equal, then the vectors are considered equal. If any are
not equal, then the vectors are not considered equal. Note that this approach means that the
calculated distance between two "equal" vectors may be as much as √(n * eps2)
,
where n
is the number of components in the vector and eps
is the maximum epsilon
value allowed by the precision context.
v
- vector to check for equalityprecision
- precision context used to determine floating point equalitypublic boolean isZero(Precision.DoubleEquivalence precision)
vec.equals(vec.getZero(), precision)
.precision
- precision context used to determine floating point equalityeq(EuclideanVector, Precision.DoubleEquivalence)
protected double getCheckedNorm()
IllegalArgumentException
if the value is not real
(ie, NaN or infinite) or zero.IllegalArgumentException
- if the vector norm is zero, NaN, or infiniteCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.