public class Vector1D extends Object implements Vector<Euclidean1D>
Instances of this class are guaranteed to be immutable.
Modifier and Type | Field and Description |
---|---|
static Vector1D |
NaN
A vector with all coordinates set to NaN.
|
static Vector1D |
NEGATIVE_INFINITY
A vector with all coordinates set to negative infinity.
|
static Vector1D |
ONE
Unit (coordinates: 1).
|
static Vector1D |
POSITIVE_INFINITY
A vector with all coordinates set to positive infinity.
|
static Vector1D |
ZERO
Origin (coordinates: 0).
|
Constructor and Description |
---|
Vector1D(double x)
Simple constructor.
|
Vector1D(double a,
Vector1D u)
Multiplicative constructor
Build a vector from another one and a scale factor.
|
Vector1D(double a1,
Vector1D u1,
double a2,
Vector1D u2)
Linear constructor
Build a vector from two other ones and corresponding scale factors.
|
Vector1D(double a1,
Vector1D u1,
double a2,
Vector1D u2,
double a3,
Vector1D u3)
Linear constructor
Build a vector from three other ones and corresponding scale factors.
|
Vector1D(double a1,
Vector1D u1,
double a2,
Vector1D u2,
double a3,
Vector1D u3,
double a4,
Vector1D u4)
Linear constructor
Build a vector from four other ones and corresponding scale factors.
|
Modifier and Type | Method and Description |
---|---|
Vector1D |
add(double factor,
Vector<Euclidean1D> v)
Add a scaled vector to the instance.
|
Vector1D |
add(Vector<Euclidean1D> v)
Add a vector to the instance.
|
double |
distance(Point<Euclidean1D> p)
Compute the distance between the instance and another point.
|
static double |
distance(Vector1D p1,
Vector1D p2)
Compute the distance between two vectors according to the L2 norm.
|
double |
distance1(Vector<Euclidean1D> p)
Compute the distance between the instance and another vector according to the L1 norm.
|
double |
distanceInf(Vector<Euclidean1D> p)
Compute the distance between the instance and another vector according to the L∞ norm.
|
static double |
distanceInf(Vector1D p1,
Vector1D p2)
Compute the distance between two vectors according to the L∞ norm.
|
double |
distanceSq(Vector<Euclidean1D> p)
Compute the square of the distance between the instance and another vector.
|
static double |
distanceSq(Vector1D p1,
Vector1D p2)
Compute the square of the distance between two vectors.
|
double |
dotProduct(Vector<Euclidean1D> v)
Compute the dot-product of the instance and another vector.
|
boolean |
equals(Object other)
Test for the equality of two 1D vectors.
|
double |
getNorm()
Get the L2 norm for the vector.
|
double |
getNorm1()
Get the L1 norm for the vector.
|
double |
getNormInf()
Get the L∞ norm for the vector.
|
double |
getNormSq()
Get the square of the norm for the vector.
|
Space |
getSpace()
Get the space to which the point belongs.
|
double |
getX()
Get the abscissa of the vector.
|
Vector1D |
getZero()
Get the null vector of the vectorial space or origin point of the affine space.
|
int |
hashCode()
Get a hashCode for the 1D vector.
|
boolean |
isInfinite()
Returns true if any coordinate of this vector is infinite and none are NaN;
false otherwise
|
boolean |
isNaN()
Returns true if any coordinate of this point is NaN; false otherwise
|
Vector1D |
negate()
Get the opposite of the instance.
|
Vector1D |
normalize()
Get a normalized vector aligned with the instance.
|
Vector1D |
scalarMultiply(double a)
Multiply the instance by a scalar.
|
Vector1D |
subtract(double factor,
Vector<Euclidean1D> v)
Subtract a scaled vector from the instance.
|
Vector1D |
subtract(Vector<Euclidean1D> p)
Subtract a vector from the instance.
|
String |
toString()
Get a string representation of this vector.
|
String |
toString(NumberFormat format)
Get a string representation of this vector.
|
public static final Vector1D ZERO
public static final Vector1D ONE
public static final Vector1D NaN
public static final Vector1D POSITIVE_INFINITY
public static final Vector1D NEGATIVE_INFINITY
public Vector1D(double x)
x
- abscissagetX()
public Vector1D(double a, Vector1D u)
a
- scale factoru
- base (unscaled) vectorpublic Vector1D(double a1, Vector1D u1, double a2, Vector1D u2)
a1
- first scale factoru1
- first base (unscaled) vectora2
- second scale factoru2
- second base (unscaled) vectorpublic Vector1D(double a1, Vector1D u1, double a2, Vector1D u2, double a3, Vector1D u3)
a1
- first scale factoru1
- first base (unscaled) vectora2
- second scale factoru2
- second base (unscaled) vectora3
- third scale factoru3
- third base (unscaled) vectorpublic Vector1D(double a1, Vector1D u1, double a2, Vector1D u2, double a3, Vector1D u3, double a4, Vector1D u4)
a1
- first scale factoru1
- first base (unscaled) vectora2
- second scale factoru2
- second base (unscaled) vectora3
- third scale factoru3
- third base (unscaled) vectora4
- fourth scale factoru4
- fourth base (unscaled) vectorpublic double getX()
Vector1D(double)
public Space getSpace()
getSpace
in interface Point<Euclidean1D>
public Vector1D getZero()
getZero
in interface Vector<Euclidean1D>
public double getNorm1()
getNorm1
in interface Vector<Euclidean1D>
public double getNorm()
getNorm
in interface Vector<Euclidean1D>
public double getNormSq()
getNormSq
in interface Vector<Euclidean1D>
public double getNormInf()
getNormInf
in interface Vector<Euclidean1D>
public Vector1D add(Vector<Euclidean1D> v)
add
in interface Vector<Euclidean1D>
v
- vector to addpublic Vector1D add(double factor, Vector<Euclidean1D> v)
add
in interface Vector<Euclidean1D>
factor
- scale factor to apply to v before adding itv
- vector to addpublic Vector1D subtract(Vector<Euclidean1D> p)
subtract
in interface Vector<Euclidean1D>
p
- vector to subtractpublic Vector1D subtract(double factor, Vector<Euclidean1D> v)
subtract
in interface Vector<Euclidean1D>
factor
- scale factor to apply to v before subtracting itv
- vector to subtractpublic Vector1D normalize() throws MathRuntimeException
normalize
in interface Vector<Euclidean1D>
MathRuntimeException
- if the norm is zeropublic Vector1D negate()
negate
in interface Vector<Euclidean1D>
public Vector1D scalarMultiply(double a)
scalarMultiply
in interface Vector<Euclidean1D>
a
- scalarpublic boolean isNaN()
isNaN
in interface Point<Euclidean1D>
public boolean isInfinite()
isInfinite
in interface Vector<Euclidean1D>
public double distance1(Vector<Euclidean1D> p)
Calling this method is equivalent to calling:
q.subtract(p).getNorm1()
except that no intermediate
vector is built
distance1
in interface Vector<Euclidean1D>
p
- second vectorpublic double distance(Point<Euclidean1D> p)
distance
in interface Point<Euclidean1D>
p
- second pointpublic double distanceInf(Vector<Euclidean1D> p)
Calling this method is equivalent to calling:
q.subtract(p).getNormInf()
except that no intermediate
vector is built
distanceInf
in interface Vector<Euclidean1D>
p
- second vectorpublic double distanceSq(Vector<Euclidean1D> p)
Calling this method is equivalent to calling:
q.subtract(p).getNormSq()
except that no intermediate
vector is built
distanceSq
in interface Vector<Euclidean1D>
p
- second vectorpublic double dotProduct(Vector<Euclidean1D> v)
dotProduct
in interface Vector<Euclidean1D>
v
- second vectorpublic static double distance(Vector1D p1, Vector1D p2)
Calling this method is equivalent to calling:
p1.subtract(p2).getNorm()
except that no intermediate
vector is built
p1
- first vectorp2
- second vectorpublic static double distanceInf(Vector1D p1, Vector1D p2)
Calling this method is equivalent to calling:
p1.subtract(p2).getNormInf()
except that no intermediate
vector is built
p1
- first vectorp2
- second vectorpublic static double distanceSq(Vector1D p1, Vector1D p2)
Calling this method is equivalent to calling:
p1.subtract(p2).getNormSq()
except that no intermediate
vector is built
p1
- first vectorp2
- second vectorpublic boolean equals(Object other)
If all coordinates of two 1D vectors are exactly the same, and none are
Double.NaN
, the two 1D vectors are considered to be equal.
NaN
coordinates are considered to affect globally the vector
and be equals to each other - i.e, if either (or all) coordinates of the
1D vector are equal to Double.NaN
, the 1D vector is equal to
NaN
.
public int hashCode()
All NaN values have the same hash code.
public String toString()
public String toString(NumberFormat format)
toString
in interface Vector<Euclidean1D>
format
- the custom format for componentsCopyright © 2016-2021 CS GROUP. All rights reserved.