public final class Vector4f extends java.lang.Object implements Savable, java.lang.Cloneable, java.io.Serializable
Vector4f defines a Vector for a four float value tuple.
 Vector4f can represent any four dimensional value, such as a
 vertex, a normal, etc. Utility methods are also included to aid in
 mathematical calculations.| Modifier and Type | Field and Description | 
|---|---|
| static Vector4f | NANshared instance of the all-NaN vector (NaN,NaN,NaN,NaN) - Do not modify! | 
| static Vector4f | NEGATIVE_INFINITYshared instance of the all-negative-infinity vector (-Inf,-Inf,-Inf,-Inf)
 - Do not modify! | 
| static Vector4f | POSITIVE_INFINITYshared instance of the all-plus-infinity vector (+Inf,+Inf,+Inf,+Inf)
 - Do not modify! | 
| static Vector4f | UNIT_Wshared instance of the +W direction (0,0,0,1) - Do not modify! | 
| static Vector4f | UNIT_Xshared instance of the +X direction (1,0,0,0) - Do not modify! | 
| static Vector4f | UNIT_XYZWshared instance of the all-ones vector (1,1,1,1) - Do not modify! | 
| static Vector4f | UNIT_Yshared instance of the +Y direction (0,1,0,0) - Do not modify! | 
| static Vector4f | UNIT_Zshared instance of the +Z direction (0,0,1,0) - Do not modify! | 
| float | wthe w value of the vector. | 
| float | xthe x value of the vector. | 
| float | ythe y value of the vector. | 
| float | zthe z value of the vector. | 
| static Vector4f | ZEROshared instance of the all-zero vector (0,0,0,0) - Do not modify! | 
| Constructor and Description | 
|---|
| Vector4f()Instantiate a  Vector4fwith the value (0,0,0,0). | 
| Vector4f(float x,
        float y,
        float z,
        float w)Constructor instantiates a new  Vector4fwith provides
 values. | 
| Vector4f(Vector4f copy)Instantiate a  Vector4fthat is a copy of the provided vector. | 
| Modifier and Type | Method and Description | 
|---|---|
| Vector4f | add(float addX,
   float addY,
   float addZ,
   float addW)addadds the provided values to this vector, creating a
 new vector that is then returned. | 
| Vector4f | add(Vector4f vec)addadds a provided vector to this vector creating a
 resultant vector which is returned. | 
| Vector4f | add(Vector4f vec,
   Vector4f result)addadds the values of a provided vector storing the
 values in the supplied vector. | 
| Vector4f | addLocal(float addX,
        float addY,
        float addZ,
        float addW)addLocaladds the provided values to this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | addLocal(Vector4f vec)addLocaladds a provided vector to this vector internally,
 and returns a handle to this vector for easy chaining of calls. | 
| float | angleBetween(Vector4f otherVector)angleBetweenreturns (in radians) the angle between two vectors. | 
| Vector4f | clone()Create a copy of this vector. | 
| float | distance(Vector4f v)distancecalculates the distance between this vector and
 vector v. | 
| float | distanceSquared(Vector4f v)distanceSquaredcalculates the distance squared between
 this vector and vector v. | 
| Vector4f | divide(float scalar)dividedivides the values of this vector by a scalar and
 returns the result. | 
| Vector4f | divide(Vector4f scalar)dividedivides the values of this vector by a scalar and
 returns the result. | 
| Vector4f | divideLocal(float scalar)divideLocaldivides this vector by a scalar internally,
 and returns a handle to this vector for easy chaining of calls. | 
| Vector4f | divideLocal(Vector4f scalar)divideLocaldivides this vector by a scalar internally,
 and returns a handle to this vector for easy chaining of calls. | 
| float | dot(Vector4f vec)dotcalculates 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. | 
| float | get(int index) | 
| float | getW()Determine the W component of this vector. | 
| float | getX()Determine the X component of this vector. | 
| float | getY()Determine the Y component of this vector. | 
| float | getZ()Determine the Z component of this vector. | 
| int | hashCode()hashCodereturns a unique code for this vector object based
 on its values. | 
| Vector4f | interpolateLocal(Vector4f finalVec,
                float changeAmnt)Sets this vector to the interpolation by changeAmnt from this to the finalVec
 this=(1-changeAmnt)*this + changeAmnt * finalVec | 
| Vector4f | interpolateLocal(Vector4f beginVec,
                Vector4f finalVec,
                float changeAmnt)Sets this vector to the interpolation by changeAmnt from beginVec to finalVec
 this=(1-changeAmnt)*beginVec + changeAmnt * finalVec | 
| boolean | isSimilar(Vector4f other,
         float epsilon)Returns true if this vector is similar to the specified vector within
 some value of epsilon. | 
| boolean | isUnitVector()Returns true if this vector is a unit vector (length() ~= 1),
 returns false otherwise. | 
| static boolean | isValidVector(Vector4f vector)Check a vector... | 
| float | length()lengthcalculates the magnitude of this vector. | 
| float | lengthSquared()lengthSquaredcalculates the squared value of the
 magnitude of the vector. | 
| Vector4f | maxLocal(Vector4f other)maxLocalcomputes the maximum value for each
 component in this andothervector. | 
| Vector4f | minLocal(Vector4f other)minLocalcomputes the minimum value for each
 component in this andothervector. | 
| Vector4f | mult(float scalar)multmultiplies this vector by a scalar. | 
| Vector4f | mult(float scalar,
    Vector4f product)multmultiplies this vector by a scalar. | 
| Vector4f | mult(Vector4f vec)multLocalmultiplies a provided vector to this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | mult(Vector4f vec,
    Vector4f store)multLocalmultiplies a provided vector to this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | multLocal(float scalar)multLocalmultiplies this vector by a scalar internally,
 and returns a handle to this vector for easy chaining of calls. | 
| Vector4f | multLocal(float x,
         float y,
         float z,
         float w)multLocalmultiplies this vector by 4 scalars
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | multLocal(Vector4f vec)multLocalmultiplies a provided vector to this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | negate()negatereturns the negative of this vector. | 
| Vector4f | negateLocal()negateLocalnegates the internal values of this vector. | 
| Vector4f | normalize()normalizereturns the unit vector of this vector. | 
| Vector4f | normalizeLocal()normalizeLocalmakes this vector into a unit vector of
 itself. | 
| Vector4f | project(Vector4f other) | 
| void | read(JmeImporter e)De-serialize this vector from the specified importer, for example
 when loading from a J3O file. | 
| Vector4f | scaleAdd(float scalar,
        Vector4f add)scaleAddmultiplies this vector by a scalar then adds the
 given Vector4f. | 
| Vector4f | scaleAdd(float scalar,
        Vector4f mult,
        Vector4f add)scaleAddmultiplies the given vector by a scalar then adds
 the given vector. | 
| Vector4f | set(float x,
   float y,
   float z,
   float w)setsets the x,y,z,w values of the vector based on passed
 parameters. | 
| void | set(int index,
   float value) | 
| Vector4f | set(Vector4f vect)setsets the x,y,z values of the vector by copying the
 supplied vector. | 
| Vector4f | setW(float w)Alter the W component of this vector. | 
| Vector4f | setX(float x)Alter the X component of this vector. | 
| Vector4f | setY(float y)Alter the Y component of this vector. | 
| Vector4f | setZ(float z)Alter the Z component of this vector. | 
| Vector4f | subtract(float subtractX,
        float subtractY,
        float subtractZ,
        float subtractW)subtractsubtracts the provided values from this vector,
 creating a new vector that is then returned. | 
| Vector4f | subtract(Vector4f vec)subtractsubtracts the values of a given vector from those
 of this vector creating a new vector object. | 
| Vector4f | subtract(Vector4f vec,
        Vector4f result)subtract | 
| Vector4f | subtractLocal(float subtractX,
             float subtractY,
             float subtractZ,
             float subtractW)subtractLocalsubtracts the provided values from this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| Vector4f | subtractLocal(Vector4f vec)subtractLocalsubtracts a provided vector to this vector
 internally, and returns a handle to this vector for easy chaining of
 calls. | 
| float[] | toArray(float[] floats)Saves this Vector4f into the given float[] object. | 
| java.lang.String | toString()toStringreturns the string representation of this vector. | 
| void | write(JmeExporter e)Serialize this vector to the specified exporter, for example when
 saving to a J3O file. | 
| Vector4f | zero()zeroresets this vector's data to zero internally. | 
public static final Vector4f ZERO
public static final Vector4f NAN
public static final Vector4f UNIT_X
public static final Vector4f UNIT_Y
public static final Vector4f UNIT_Z
public static final Vector4f UNIT_W
public static final Vector4f UNIT_XYZW
public static final Vector4f POSITIVE_INFINITY
public static final Vector4f NEGATIVE_INFINITY
public float x
public float y
public float z
public float w
public Vector4f()
Vector4f with the value (0,0,0,0).public Vector4f(float x,
                float y,
                float z,
                float w)
Vector4f with provides
 values.x - the x value of the vector.y - the y value of the vector.z - the z value of the vector.w - the w value of the vector.public Vector4f(Vector4f copy)
Vector4f that is a copy of the provided vector.copy - The Vector4f to copypublic Vector4f set(float x, float y, float z, float w)
set sets the x,y,z,w 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.w - the w value of the vector.public Vector4f set(Vector4f vect)
set sets the x,y,z values of the vector by copying the
 supplied vector.vect - the vector to copy.public Vector4f add(Vector4f 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 Vector4f add(Vector4f vec, Vector4f 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 Vector4f addLocal(Vector4f 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 Vector4f add(float addX, float addY, float addZ, float addW)
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.addW - the w value to add.public Vector4f addLocal(float addX, float addY, float addZ, float addW)
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 zaddW - the w value to add.public Vector4f scaleAdd(float scalar, Vector4f add)
scaleAdd multiplies this vector by a scalar then adds the
 given Vector4f.scalar - the value to multiply this vector by.add - the value to addpublic Vector4f scaleAdd(float scalar, Vector4f mult, Vector4f 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 float dot(Vector4f 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 boolean isUnitVector()
public float length()
length calculates the magnitude of this vector.public float lengthSquared()
lengthSquared calculates the squared value of the
 magnitude of the vector.public float distanceSquared(Vector4f v)
distanceSquared calculates the distance squared between
 this vector and vector v.v - the second vector to determine the distance squared.public float distance(Vector4f v)
distance calculates the distance between this vector and
 vector v.v - the second vector to determine the distance.public Vector4f mult(float scalar)
mult multiplies this vector by a scalar. The resultant
 vector is returned.scalar - the value to multiply this vector by.public Vector4f mult(float scalar, Vector4f 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 Vector4f multLocal(float 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 Vector4f multLocal(Vector4f 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 Vector4f multLocal(float x, float y, float z, float w)
multLocal multiplies this vector by 4 scalars
 internally, and returns a handle to this vector for easy chaining of
 calls.x - y - z - w - public Vector4f mult(Vector4f 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 Vector4f mult(Vector4f vec, Vector4f 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 Vector4f divide(float 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 Vector4f divideLocal(float 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 Vector4f divide(Vector4f 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 Vector4f divideLocal(Vector4f 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 Vector4f negate()
negate returns the negative of this vector. All values are
 negated and set to a new vector.public Vector4f negateLocal()
negateLocal negates the internal values of this vector.public Vector4f subtract(Vector4f 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 Vector4f subtractLocal(Vector4f 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 Vector4f subtract(Vector4f vec, Vector4f result)
subtractvec - the vector to subtract from thisresult - the vector to store the result inpublic Vector4f subtract(float subtractX, float subtractY, float subtractZ, float subtractW)
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.subtractW - the w value to subtract.public Vector4f subtractLocal(float subtractX, float subtractY, float subtractZ, float subtractW)
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.subtractW - the w value to subtract.public Vector4f normalize()
normalize returns the unit vector of this vector.public Vector4f normalizeLocal()
normalizeLocal makes this vector into a unit vector of
 itself.public Vector4f maxLocal(Vector4f other)
maxLocal computes the maximum value for each
 component in this and other vector. The result is stored
 in this vector.other - public Vector4f minLocal(Vector4f other)
minLocal computes the minimum value for each
 component in this and other vector. The result is stored
 in this vector.other - public Vector4f zero()
zero resets this vector's data to zero internally.public float angleBetween(Vector4f 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 Vector4f interpolateLocal(Vector4f finalVec, float changeAmnt)
finalVec - The final vector to interpolate towardschangeAmnt - An amount between 0.0 - 1.0 representing a percentage
  change from this towards finalVecpublic Vector4f interpolateLocal(Vector4f beginVec, Vector4f finalVec, float changeAmnt)
beginVec - the beginning vector (changeAmnt=0)finalVec - The final vector to interpolate towardschangeAmnt - An amount between 0.0 - 1.0 representing a percentage
  change from beginVec towards finalVecpublic static boolean isValidVector(Vector4f vector)
vector - the vector to checkpublic Vector4f clone()
clone in class java.lang.Objectpublic float[] toArray(float[] floats)
floats - The float[] to take this Vector4f. If null, a new float[4] is
            created.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to compare for equalitypublic boolean isSimilar(Vector4f other, float epsilon)
other - the vector to compare with (not null, unaffected)epsilon - the desired error tolerance for each componentpublic int hashCode()
hashCode returns a unique code for this vector object based
 on its values. If two vectors are logically equivalent, they will return
 the same hash code value.hashCode in class java.lang.Objectpublic java.lang.String toString()
toString returns the string representation of this vector.
 The format is:
 (XX.XXXX, YY.YYYY, ZZ.ZZZZ, WW.WWWW)toString in class java.lang.Objectpublic void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public float getX()
public Vector4f setX(float x)
x - the desired valuepublic float getY()
public Vector4f setY(float y)
y - the desired valuepublic float getZ()
public Vector4f setZ(float z)
z - the desired valuepublic float getW()
public Vector4f setW(float w)
w - the desired valuepublic float get(int index)
index - java.lang.IllegalArgumentException - if index is not one of 0, 1, 2.public void set(int index,
                float value)
index - which field index in this vector to set.value - to set to one of x, y, z or w.java.lang.IllegalArgumentException - if index is not one of 0, 1, 2, 3.