public class Vector3 extends Matrix implements Externalizable
A 3-dimensional vector.
This class and all it subclasses are mutable, therefore it should only be used to hold intermediate results, and never shared among threads.| Modifier | Constructor and Description |
|---|---|
protected |
Vector3() |
protected |
Vector3(double e0,
double e1,
double e2) |
protected |
Vector3(Vector3 vec) |
| Modifier and Type | Method and Description |
|---|---|
Vector3 |
add(Vector3 vec)
Adds (destructively) a given vector to this vector
|
static Vector3 |
add(Vector3 vec1,
Vector3 vec2)
Adds two vectors.
|
static Vector3 |
cross(Vector3 vec1,
Vector3 vec2)
Computes the cross product of two vectors.
|
static double |
dot(Vector3 vec1,
Vector3 vec2)
Computes the dot product of two vectors.
|
boolean |
equals(Object obj) |
double |
get(int coordIndex)
Returns the value of a given coordinate
|
int |
hashCode() |
double |
norm()
Returns the norm of this vector
|
double |
normSqr()
Returns the norm of this vector, squared
|
void |
readExternal(ObjectInput in) |
Vector3 |
scale(double value)
Scaled (destructively) this vector by a given value
|
static Vector3 |
scale(Vector3 vec,
double value)
Scales a vector by a scalar.
|
protected void |
set(double coord0,
double coord1,
double coord2)
Sets this vector to the given coordinates
|
void |
set(int coordIndex,
double value)
Sets the specified coordinate to the given value
|
void |
set(Vector3 vec)
Sets this vector to the value of a given vector
|
Vector3 |
sub(Vector3 vec)
Subtracts (destructively) a given vector from this vector
|
static Vector3 |
sub(Vector3 vec1,
Vector3 vec2)
Subtracts two vectors.
|
String |
toString() |
Matrix |
toVector4() |
void |
writeExternal(ObjectOutput out) |
protected Vector3()
protected Vector3(double e0,
double e1,
double e2)
protected Vector3(Vector3 vec)
public final void set(int coordIndex,
double value)
Sets the specified coordinate to the given value
coordIndex - the coordinate index (0-2)value - the valuepublic final void set(Vector3 vec)
Sets this vector to the value of a given vector
vec - public double get(int coordIndex)
Returns the value of a given coordinate
coordIndex - the coordinate index (0-2)protected final void set(double coord0,
double coord1,
double coord2)
Sets this vector to the given coordinates
public Matrix toVector4()
public double norm()
Returns the norm of this vector
public double normSqr()
Returns the norm of this vector, squared
public Vector3 add(Vector3 vec)
Adds (destructively) a given vector to this vector
vec - the vector to addthispublic Vector3 sub(Vector3 vec)
Subtracts (destructively) a given vector from this vector
vec - the vector to subtractthispublic Vector3 scale(double value)
Scaled (destructively) this vector by a given value
value - the amount by which to scale this vectorthispublic static Vector3 add(Vector3 vec1, Vector3 vec2)
Adds two vectors. Both vector arguments remain unmodified.
vec1 - the first vectorvec2 - the second vectorpublic static Vector3 sub(Vector3 vec1, Vector3 vec2)
Subtracts two vectors. Both vector arguments remain unmodified.
vec1 - the first vector, from which we subtractvec2 - the second vector, to be subtracted from the firstvec1 - vec2.public static Vector3 scale(Vector3 vec, double value)
Scales a vector by a scalar. The vector argument remains unmodified.
vec - the vector to scalevalue - the value by which to scale the vectorpublic static double dot(Vector3 vec1, Vector3 vec2)
Computes the dot product of two vectors.
vec1 - the first vectorvec2 - the second vectorvec1 and vec2public static Vector3 cross(Vector3 vec1, Vector3 vec2)
Computes the cross product of two vectors.
vec1 - the first vectorvec2 - the second vectorvec1 and vec2, i.e. vec1 x vec2public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundException