Vector
, java.io.Serializable
public final class Vector3D extends java.lang.Object implements Vector, java.io.Serializable
Modifier and Type | Field | Description |
---|---|---|
protected static double[] |
lookUp |
|
protected static int |
nLookUp |
|
protected double |
x |
|
protected double |
y |
|
protected double |
z |
Constructor | Description |
---|---|
Vector3D() |
|
Vector3D(double[] a) |
|
Vector3D(double a1,
double a2,
double a3) |
|
Vector3D(Vector3D u) |
Modifier and Type | Method | Description |
---|---|---|
void |
assignTo(double[] array) |
Assigns the components of this vector to the elements of the given array.
|
protected static double |
cubeRoot(double R) |
|
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,
double c) |
|
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
|
void |
mod(Vector3D 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 |
setPerpendicularTo(Vector v) |
|
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) |
Creating a random unit vector on unit sphere Uses only two random number
generator at a time
Based on M.P.
|
void |
setX(int a,
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).
|
protected double x
protected double y
protected double z
protected static final int nLookUp
protected static final double[] lookUp
public Vector3D()
public Vector3D(double a1, double a2, double a3)
public Vector3D(double[] a)
public Vector3D(Vector3D u)
public int getD()
Vector
public java.lang.String toString()
toString
in class java.lang.Object
public double getX(int i)
Vector
public void assignTo(double[] array)
Vector
public boolean equals(Vector v)
Vector
public boolean isZero()
Vector
public void E(Vector u)
Vector
public void E(double a)
Vector
public void E(double a, double b, double c)
public void E(double[] u)
Vector
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 void Ev1Pv2(Vector u1, Vector u2)
Vector
public void Ev1Mv2(Vector u1, Vector u2)
Vector
public void mod(Vector u)
Vector
public void mod(Vector3D u)
public double squared()
Vector
public double Mv1Squared(Vector u)
Vector
Mv1Squared
in interface Vector
public double dot(Vector u)
Vector
public void setPerpendicularTo(Vector v)
public void setX(int a, double d)
Vector
public void setRandomCube(IRandom random)
Vector
setRandomCube
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 void setRandomSphere(IRandom random)
setRandomSphere
in interface Vector
random
- the random number generator used to perform the operationpublic void XE(Vector u)
Vector
public void normalize()
Vector
public boolean isNaN()
Vector
public void map(IFunction function)
Vector
protected static double cubeRoot(double R)