public final class Vector3d extends java.lang.Object implements Savable, java.lang.Cloneable, java.io.Serializable
Vector3d
defines a Vector for a three float value tuple. Vector3d
can represent any three dimensional value, such as a
vertex, a normal, etc. Utility methods are also included to aid in
mathematical calculations.
This class's only purpose is to give better accuracy in floating point operations during computations.
This is made by copying the original Vector3f class from jme3 core and leaving only required methods and basic computation methods, so that
the class is smaller and easier to maintain.
Should any other methods be needed, they will be added.Modifier and Type  Field and Description 

static Vector3d 
UNIT_X 
static Vector3d 
UNIT_XYZ 
static Vector3d 
UNIT_Y 
static Vector3d 
UNIT_Z 
double 
x
the x value of the vector.

double 
y
the y value of the vector.

double 
z
the z value of the vector.

static Vector3d 
ZERO 
Constructor and Description 

Vector3d()
Constructor instantiates a new
Vector3d with default
values of (0,0,0). 
Vector3d(double x,
double y,
double z)
Constructor instantiates a new
Vector3d with provides
values. 
Vector3d(Vector3f vector3f)
Constructor instantiates a new
Vector3d that is a copy
of the provided vector 
Modifier and Type  Method and Description 

Vector3d 
add(double addX,
double addY,
double addZ)
add adds the provided values to this vector, creating a
new vector that is then returned. 
Vector3d 
add(Vector3d vec)
add adds a provided vector to this vector creating a
resultant vector which is returned. 
Vector3d 
add(Vector3d vec,
Vector3d result)
add adds the values of a provided vector storing the
values in the supplied vector. 
Vector3d 
addLocal(double addX,
double addY,
double addZ)
addLocal adds the provided values to this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
addLocal(Vector3d vec)
addLocal adds a provided vector to this vector internally,
and returns a handle to this vector for easy chaining of calls. 
double 
angleBetween(Vector3d otherVector)
angleBetween returns (in radians) the angle between two vectors. 
Vector3d 
clone() 
Vector3d 
cross(double otherX,
double otherY,
double otherZ,
Vector3d result)
cross calculates the cross product of this vector with a
parameter vector v. 
Vector3d 
cross(Vector3d v)
cross calculates the cross product of this vector with a
parameter vector v. 
Vector3d 
cross(Vector3d v,
Vector3d result)
cross calculates the cross product of this vector with a
parameter vector v. 
Vector3d 
crossLocal(double otherX,
double otherY,
double otherZ)
crossLocal calculates the cross product of this vector
with a parameter vector v. 
Vector3d 
crossLocal(Vector3d v)
crossLocal calculates the cross product of this vector
with a parameter vector v. 
double 
distance(Vector3d v)
distance calculates the distance between this vector and
vector v. 
double 
distanceSquared(Vector3d v)
distanceSquared calculates the distance squared between
this vector and vector v. 
Vector3d 
divide(double scalar)
divide divides the values of this vector by a scalar and
returns the result. 
Vector3d 
divide(Vector3d scalar)
divide divides the values of this vector by a scalar and
returns the result. 
Vector3d 
divideLocal(double scalar)
divideLocal divides this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls. 
Vector3d 
divideLocal(Vector3d scalar)
divideLocal divides this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls. 
double 
dot(Vector3d vec)
dot calculates the dot product of this vector with a
provided vector. 
boolean 
equals(java.lang.Object o)
are these two vectors the same? they are is they both have the same x,y,
and z values.

int 
hashCode()
hashCode returns a unique code for this vector object based
on it's values. 
double 
length()
length calculates the magnitude of this vector. 
double 
lengthSquared()
lengthSquared calculates the squared value of the
magnitude of the vector. 
Vector3d 
mult(double scalar)
mult multiplies this vector by a scalar. 
Vector3d 
mult(double scalar,
Vector3d product)
mult multiplies this vector by a scalar. 
Vector3d 
mult(Vector3d vec)
multLocal multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
mult(Vector3d vec,
Vector3d store)
multLocal multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
multLocal(double scalar)
multLocal multiplies this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls. 
Vector3d 
multLocal(double x,
double y,
double z)
multLocal multiplies this vector by 3 scalars
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
multLocal(Vector3d vec)
multLocal multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
negate()
negate returns the negative of this vector. 
Vector3d 
negateLocal()
negateLocal negates the internal values of this vector. 
Vector3d 
normalize()
normalize returns the unit vector of this vector. 
Vector3d 
normalizeLocal()
normalizeLocal makes this vector into a unit vector of
itself. 
void 
read(JmeImporter e) 
Vector3d 
scaleAdd(double scalar,
Vector3d add)
scaleAdd multiplies this vector by a scalar then adds the
given Vector3d. 
Vector3d 
scaleAdd(double scalar,
Vector3d mult,
Vector3d add)
scaleAdd multiplies the given vector by a scalar then adds
the given vector. 
Vector3d 
set(double x,
double y,
double z)
set sets the x,y,z values of the vector based on passed
parameters. 
Vector3d 
set(Vector3d vect)
set sets the x,y,z values of the vector by copying the
supplied vector. 
Vector3d 
subtract(double subtractX,
double subtractY,
double subtractZ)
subtract subtracts the provided values from this vector,
creating a new vector that is then returned. 
Vector3d 
subtract(Vector3d vec)
subtract subtracts the values of a given vector from those
of this vector creating a new vector object. 
Vector3d 
subtract(Vector3d vec,
Vector3d result)
subtract 
Vector3d 
subtractLocal(double subtractX,
double subtractY,
double subtractZ)
subtractLocal subtracts the provided values from this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
Vector3d 
subtractLocal(Vector3d vec)
subtractLocal subtracts a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. 
java.lang.String 
toString()
toString returns the string representation of this vector. 
Vector3f 
toVector3f() 
void 
write(JmeExporter e) 
public static final Vector3d ZERO
public static final Vector3d UNIT_XYZ
public static final Vector3d UNIT_X
public static final Vector3d UNIT_Y
public static final Vector3d UNIT_Z
public double x
public double y
public double z
public Vector3d()
Vector3d
with default
values of (0,0,0).public Vector3d(double x, double y, double z)
Vector3d
with provides
values.x
 the x value of the vector.y
 the y value of the vector.z
 the z value of the vector.public Vector3d(Vector3f vector3f)
Vector3d
that is a copy
of the provided vectorcopy
 The Vector3d to copypublic Vector3f toVector3f()
public Vector3d set(double x, double y, double z)
set
sets the x,y,z values of the vector based on passed
parameters.x
 the x value of the vector.y
 the y value of the vector.z
 the z value of the vector.public Vector3d set(Vector3d vect)
set
sets the x,y,z values of the vector by copying the
supplied vector.vect
 the vector to copy.public Vector3d add(Vector3d vec)
add
adds a provided vector to this vector creating a
resultant vector which is returned. If the provided vector is null, null
is returned.vec
 the vector to add to this.public Vector3d add(Vector3d vec, Vector3d result)
add
adds the values of a provided vector storing the
values in the supplied vector.vec
 the vector to add to thisresult
 the vector to store the result inpublic Vector3d addLocal(Vector3d vec)
addLocal
adds a provided vector to this vector internally,
and returns a handle to this vector for easy chaining of calls. If the
provided vector is null, null is returned.vec
 the vector to add to this vector.public Vector3d add(double addX, double addY, double addZ)
add
adds the provided values to this vector, creating a
new vector that is then returned.addX
 the x value to add.addY
 the y value to add.addZ
 the z value to add.public Vector3d addLocal(double addX, double addY, double addZ)
addLocal
adds the provided values to this vector
internally, and returns a handle to this vector for easy chaining of
calls.addX
 value to add to xaddY
 value to add to yaddZ
 value to add to zpublic Vector3d scaleAdd(double scalar, Vector3d add)
scaleAdd
multiplies this vector by a scalar then adds the
given Vector3d.scalar
 the value to multiply this vector by.add
 the value to addpublic Vector3d scaleAdd(double scalar, Vector3d mult, Vector3d add)
scaleAdd
multiplies the given vector by a scalar then adds
the given vector.scalar
 the value to multiply this vector by.mult
 the value to multiply the scalar byadd
 the value to addpublic double dot(Vector3d vec)
dot
calculates the dot product of this vector with a
provided vector. If the provided vector is null, 0 is returned.vec
 the vector to dot with this vector.public Vector3d cross(Vector3d v)
cross
calculates the cross product of this vector with a
parameter vector v.v
 the vector to take the cross product of with this.public Vector3d cross(Vector3d v, Vector3d result)
cross
calculates the cross product of this vector with a
parameter vector v. The result is stored in result
v
 the vector to take the cross product of with this.result
 the vector to store the cross product result.public Vector3d cross(double otherX, double otherY, double otherZ, Vector3d result)
cross
calculates the cross product of this vector with a
parameter vector v. The result is stored in result
otherX
 x component of the vector to take the cross product of with this.otherY
 y component of the vector to take the cross product of with this.otherZ
 z component of the vector to take the cross product of with this.result
 the vector to store the cross product result.public Vector3d crossLocal(Vector3d v)
crossLocal
calculates the cross product of this vector
with a parameter vector v.v
 the vector to take the cross product of with this.public Vector3d crossLocal(double otherX, double otherY, double otherZ)
crossLocal
calculates the cross product of this vector
with a parameter vector v.otherX
 x component of the vector to take the cross product of with this.otherY
 y component of the vector to take the cross product of with this.otherZ
 z component of the vector to take the cross product of with this.public double length()
length
calculates the magnitude of this vector.public double lengthSquared()
lengthSquared
calculates the squared value of the
magnitude of the vector.public double distanceSquared(Vector3d v)
distanceSquared
calculates the distance squared between
this vector and vector v.v
 the second vector to determine the distance squared.public double distance(Vector3d v)
distance
calculates the distance between this vector and
vector v.v
 the second vector to determine the distance.public Vector3d mult(double scalar)
mult
multiplies this vector by a scalar. The resultant
vector is returned.scalar
 the value to multiply this vector by.public Vector3d mult(double scalar, Vector3d product)
mult
multiplies this vector by a scalar. The resultant
vector is supplied as the second parameter and returned.scalar
 the scalar to multiply this vector by.product
 the product to store the result in.public Vector3d multLocal(double scalar)
multLocal
multiplies this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls.scalar
 the value to multiply this vector by.public Vector3d multLocal(Vector3d vec)
multLocal
multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. If the provided vector is null, null is returned.vec
 the vector to mult to this vector.public Vector3d multLocal(double x, double y, double z)
multLocal
multiplies this vector by 3 scalars
internally, and returns a handle to this vector for easy chaining of
calls.x
 y
 z
 public Vector3d mult(Vector3d vec)
multLocal
multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. If the provided vector is null, null is returned.vec
 the vector to mult to this vector.public Vector3d mult(Vector3d vec, Vector3d store)
multLocal
multiplies a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. If the provided vector is null, null is returned.vec
 the vector to mult to this vector.store
 result vector (null to create a new vector)public Vector3d divide(double scalar)
divide
divides the values of this vector by a scalar and
returns the result. The values of this vector remain untouched.scalar
 the value to divide this vectors attributes by.Vector
.public Vector3d divideLocal(double scalar)
divideLocal
divides this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls. Dividing
by zero will result in an exception.scalar
 the value to divides this vector by.public Vector3d divide(Vector3d scalar)
divide
divides the values of this vector by a scalar and
returns the result. The values of this vector remain untouched.scalar
 the value to divide this vectors attributes by.Vector
.public Vector3d divideLocal(Vector3d scalar)
divideLocal
divides this vector by a scalar internally,
and returns a handle to this vector for easy chaining of calls. Dividing
by zero will result in an exception.scalar
 the value to divides this vector by.public Vector3d negate()
negate
returns the negative of this vector. All values are
negated and set to a new vector.public Vector3d negateLocal()
negateLocal
negates the internal values of this vector.public Vector3d subtract(Vector3d vec)
subtract
subtracts the values of a given vector from those
of this vector creating a new vector object. If the provided vector is
null, null is returned.vec
 the vector to subtract from this vector.public Vector3d subtractLocal(Vector3d vec)
subtractLocal
subtracts a provided vector to this vector
internally, and returns a handle to this vector for easy chaining of
calls. If the provided vector is null, null is returned.vec
 the vector to subtractpublic Vector3d subtract(Vector3d vec, Vector3d result)
subtract
vec
 the vector to subtract from thisresult
 the vector to store the result inpublic Vector3d subtract(double subtractX, double subtractY, double subtractZ)
subtract
subtracts the provided values from this vector,
creating a new vector that is then returned.subtractX
 the x value to subtract.subtractY
 the y value to subtract.subtractZ
 the z value to subtract.public Vector3d subtractLocal(double subtractX, double subtractY, double subtractZ)
subtractLocal
subtracts the provided values from this vector
internally, and returns a handle to this vector for easy chaining of
calls.subtractX
 the x value to subtract.subtractY
 the y value to subtract.subtractZ
 the z value to subtract.public Vector3d normalize()
normalize
returns the unit vector of this vector.public Vector3d normalizeLocal()
normalizeLocal
makes this vector into a unit vector of
itself.public double angleBetween(Vector3d otherVector)
angleBetween
returns (in radians) the angle between two vectors.
It is assumed that both this vector and the given vector are unit vectors (iow, normalized).otherVector
 a unit vector to find the angle againstpublic Vector3d clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
 the object to compare for equalitypublic int hashCode()
hashCode
returns a unique code for this vector object based
on it's values. If two vectors are logically equivalent, they will return
the same hash code value.hashCode
in class java.lang.Object
public java.lang.String toString()
toString
returns the string representation of this vector.
The format is:
org.jme.math.Vector3d [X=XX.XXXX, Y=YY.YYYY, Z=ZZ.ZZZZ]toString
in class java.lang.Object
public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException