Vector
, java.io.Serializable
public final class Vector2D extends java.lang.Object implements Vector, java.io.Serializable
Constructor | Description |
---|---|
Vector2D() |
|
Vector2D(double[] a) |
|
Vector2D(double x,
double y) |
|
Vector2D(Vector2D u) |
Modifier and Type | Method | Description |
---|---|---|
void |
assignTo(double[] array) |
Assigns the components of this vector to the elements of the given array.
|
void |
DE(Vector u) |
Divide-equals (/=) operation.
|
double |
dot(Vector u) |
Returns the dot product of this vector with the given one.
|
void |
E(double a) |
Sets all components of this vector equal to the given value.
|
void |
E(double[] u) |
Sets the components of this vector equal to the corresponding elements of
the given array.
|
void |
E(double a,
double b) |
|
void |
E(Vector u) |
Sets the components of this vector equal to those of the given vector.
|
void |
Ea1Tv1(double a1,
Vector u) |
Operation (= a1 * v1); sets the components of this to those of the given
vector multiplied by the given constant.
|
boolean |
equals(Vector v) |
Returns true if all corresponding elements of this and the given vector
are equal; returns false otherwise.
|
void |
Ev1Mv2(Vector u1,
Vector u2) |
Sets the components of this vector equal to (v1 - v2)
|
void |
Ev1Pv2(Vector u1,
Vector u2) |
Sets the components of this vector equal to (v1 + v2)
|
int |
getD() |
Dimension of the space occupied by the vector.
|
double |
getX(int i) |
Vector components corresponding to the given index.
|
boolean |
isNaN() |
Returns true if any element of the vector is not-a-number.
|
boolean |
isZero() |
Returns true if all components of this vector are zero; false otherwise.
|
void |
map(IFunction function) |
Applies the given function to each element of the vector.
|
void |
ME(Vector u) |
Minus-equals (-=) operation.
|
void |
mod(Vector u) |
Replaces each component of this vector with its value modulo
the corresponding component in u
|
double |
Mv1Squared(Vector u) |
Returns square of vector resulting from subtracting given vector
from this one.
|
void |
nearestImage(Vector dimensions) |
|
void |
normalize() |
Normalizes this vector, so this.squared() == 1.
|
void |
PE(double a) |
Plus-equals (+=) operation, causing a constant value to be added to all
components of this vector.
|
void |
PE(Vector u) |
Plus-equals (+=) operation.
|
void |
PEa1Tv1(double a1,
Vector u) |
Increments (+=) components by (a1 * v1)
|
void |
setRandomCube(IRandom random) |
Assigns each component to (its own) random value between -0.5 and + 0.5.
|
void |
setRandomInSphere(IRandom random) |
Assigns this vector to equal a point chosen randomly in the volume
of a unit sphere.
|
void |
setRandomSphere(IRandom random) |
Assigns this vector to equal a point chosen randomly on the
surface of a unit sphere.
|
void |
setX(int i,
double d) |
Sets the i-th component of the vector to the given value d.
|
double |
squared() |
Returns the square magnitude of this vector, e.g., x^2 + y^2 for D = 2.
|
void |
TE(double a) |
Multiplies all components by a constant.
|
void |
TE(Vector u) |
Times-equals (*=) operation.
|
java.lang.String |
toString() |
|
void |
XE(Vector u) |
Sets this vector equal to the cross product of this vector with the
given vector (only works for 3D vectors).
|
public Vector2D()
public Vector2D(double x, double y)
public Vector2D(double[] a)
public Vector2D(Vector2D u)
public java.lang.String toString()
toString
in class java.lang.Object
public void assignTo(double[] array)
Vector
public boolean equals(Vector v)
Vector
public boolean isZero()
Vector
public int getD()
Vector
public double getX(int i)
Vector
public void setX(int i, double d)
Vector
public void E(Vector u)
Vector
public void E(double[] u)
Vector
public void E(double a)
Vector
public void E(double a, double b)
public void Ea1Tv1(double a1, Vector u)
Vector
public void PEa1Tv1(double a1, Vector u)
Vector
public void PE(Vector u)
Vector
public void PE(double a)
Vector
public void ME(Vector u)
Vector
public void TE(double a)
Vector
public void TE(Vector u)
Vector
public void DE(Vector u)
Vector
public double Mv1Squared(Vector u)
Vector
Mv1Squared
in interface Vector
public void Ev1Pv2(Vector u1, Vector u2)
Vector
public void Ev1Mv2(Vector u1, Vector u2)
Vector
public void mod(Vector u)
Vector
public double squared()
Vector
public double dot(Vector u)
Vector
public void normalize()
Vector
public void setRandomCube(IRandom random)
Vector
setRandomCube
in interface Vector
random
- the random number generator used to perform the operationpublic void setRandomSphere(IRandom random)
Vector
setRandomSphere
in interface Vector
random
- the random number generator used to perform the operationpublic void setRandomInSphere(IRandom random)
Vector
setRandomInSphere
in interface Vector
random
- the random number generator used to perform the operationpublic void nearestImage(Vector dimensions)
nearestImage
in interface Vector
public boolean isNaN()
Vector
public void map(IFunction function)
Vector