com.jme3.math
クラス Vector4f

java.lang.Object
  上位を拡張 com.jme3.math.Vector4f
すべての実装されたインタフェース:
Savable, java.io.Serializable, java.lang.Cloneable

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.

関連項目:
直列化された形式

フィールドの概要
static Vector4f NAN
           
static Vector4f NEGATIVE_INFINITY
           
static Vector4f POSITIVE_INFINITY
           
static Vector4f UNIT_W
           
static Vector4f UNIT_X
           
static Vector4f UNIT_XYZW
           
static Vector4f UNIT_Y
           
static Vector4f UNIT_Z
           
 float w
          the w value of the vector.
 float x
          the x value of the vector.
 float y
          the y value of the vector.
 float z
          the z value of the vector.
static Vector4f ZERO
           
 
コンストラクタの概要
Vector4f()
          Constructor instantiates a new Vector3f with default values of (0,0,0).
Vector4f(float x, float y, float z, float w)
          Constructor instantiates a new Vector4f with provides values.
Vector4f(Vector4f copy)
          Constructor instantiates a new Vector3f that is a copy of the provided vector
 
メソッドの概要
 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.
 Vector4f add(Vector4f vec)
          add adds a provided vector to this vector creating a resultant vector which is returned.
 Vector4f add(Vector4f vec, Vector4f result)
          add adds the values of a provided vector storing the values in the supplied vector.
 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.
 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.
 float angleBetween(Vector4f otherVector)
          angleBetween returns (in radians) the angle between two vectors.
 Vector4f clone()
           
 float distance(Vector4f v)
          distance calculates the distance between this vector and vector v.
 float distanceSquared(Vector4f v)
          distanceSquared calculates the distance squared between this vector and vector v.
 Vector4f divide(float scalar)
          divide divides the values of this vector by a scalar and returns the result.
 Vector4f divide(Vector4f scalar)
          divide divides the values of this vector by a scalar and returns the result.
 Vector4f divideLocal(float scalar)
          divideLocal divides this vector by a scalar internally, and returns a handle to this vector for easy chaining of calls.
 Vector4f divideLocal(Vector4f scalar)
          divideLocal divides this vector by a scalar internally, and returns a handle to this vector for easy chaining of calls.
 float dot(Vector4f 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?
 float get(int index)
           
 float getW()
           
 float getX()
           
 float getY()
           
 float getZ()
           
 int hashCode()
          hashCode returns a unique code for this vector object based on it's values.
 Vector4f interpolate(Vector4f finalVec, float changeAmnt)
          Sets this vector to the interpolation by changeAmnt from this to the finalVec this=(1-changeAmnt)*this + changeAmnt * finalVec
 Vector4f interpolate(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 isUnitVector()
          Returns true if this vector is a unit vector (length() ~= 1), returns false otherwise.
static boolean isValidVector(Vector4f vector)
          Check a vector... if it is null or its floats are NaN or infinite, return false.
 float length()
          length calculates the magnitude of this vector.
 float lengthSquared()
          lengthSquared calculates the squared value of the magnitude of the vector.
 void maxLocal(Vector4f other)
          maxLocal computes the maximum value for each component in this and other vector.
 void minLocal(Vector4f other)
          minLocal computes the minimum value for each component in this and other vector.
 Vector4f mult(float scalar)
          mult multiplies this vector by a scalar.
 Vector4f mult(float scalar, Vector4f product)
          mult multiplies this vector by a scalar.
 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.
 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.
 Vector4f multLocal(float scalar)
          multLocal multiplies 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)
          multLocal multiplies this vector by 3 scalars internally, and returns a handle to this vector for easy chaining of calls.
 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.
 Vector4f negate()
          negate returns the negative of this vector.
 Vector4f negateLocal()
          negateLocal negates the internal values of this vector.
 Vector4f normalize()
          normalize returns the unit vector of this vector.
 Vector4f normalizeLocal()
          normalizeLocal makes this vector into a unit vector of itself.
 Vector4f project(Vector4f other)
           
 void read(JmeImporter e)
           
 Vector4f scaleAdd(float scalar, Vector4f add)
          scaleAdd multiplies this vector by a scalar then adds the given Vector3f.
 Vector4f scaleAdd(float scalar, Vector4f mult, Vector4f add)
          scaleAdd multiplies the given vector by a scalar then adds the given vector.
 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.
 void set(int index, float value)
           
 Vector4f set(Vector4f vect)
          set sets the x,y,z values of the vector by copying the supplied vector.
 Vector4f setW(float w)
           
 Vector4f setX(float x)
           
 Vector4f setY(float y)
           
 Vector4f setZ(float z)
           
 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.
 Vector4f subtract(Vector4f vec)
          subtract subtracts 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)
          subtractLocal subtracts the provided values from this vector internally, and returns a handle to this vector for easy chaining of calls.
 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.
 float[] toArray(float[] floats)
          Saves this Vector3f into the given float[] object.
 java.lang.String toString()
          toString returns the string representation of this vector.
 void write(JmeExporter e)
           
 Vector4f zero()
          zero resets this vector's data to zero internally.
 
クラス java.lang.Object から継承されたメソッド
getClass, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

ZERO

public static final Vector4f ZERO

NAN

public static final Vector4f NAN

UNIT_X

public static final Vector4f UNIT_X

UNIT_Y

public static final Vector4f UNIT_Y

UNIT_Z

public static final Vector4f UNIT_Z

UNIT_W

public static final Vector4f UNIT_W

UNIT_XYZW

public static final Vector4f UNIT_XYZW

POSITIVE_INFINITY

public static final Vector4f POSITIVE_INFINITY

NEGATIVE_INFINITY

public static final Vector4f NEGATIVE_INFINITY

x

public float x
the x value of the vector.


y

public float y
the y value of the vector.


z

public float z
the z value of the vector.


w

public float w
the w value of the vector.

コンストラクタの詳細

Vector4f

public Vector4f()
Constructor instantiates a new Vector3f with default values of (0,0,0).


Vector4f

public Vector4f(float x,
                float y,
                float z,
                float w)
Constructor instantiates a new 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.

Vector4f

public Vector4f(Vector4f copy)
Constructor instantiates a new Vector3f that is a copy of the provided vector

パラメータ:
copy - The Vector3f to copy
メソッドの詳細

set

public 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.
戻り値:
this vector

set

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.
戻り値:
this vector

add

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.
戻り値:
the resultant vector.

add

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 this
result - the vector to store the result in
戻り値:
result returns the supplied result vector.

addLocal

public 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.
戻り値:
this

add

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.
戻り値:
the result vector.

addLocal

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 x
addY - value to add to y
addZ - value to add to z
戻り値:
this

scaleAdd

public Vector4f scaleAdd(float scalar,
                         Vector4f add)
scaleAdd multiplies this vector by a scalar then adds the given Vector3f.

パラメータ:
scalar - the value to multiply this vector by.
add - the value to add

scaleAdd

public 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 by
add - the value to add

dot

public 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.
戻り値:
the resultant dot product of this vector and a given vector.

project

public Vector4f project(Vector4f other)

isUnitVector

public boolean isUnitVector()
Returns true if this vector is a unit vector (length() ~= 1), returns false otherwise.

戻り値:
true if this vector is a unit vector (length() ~= 1), or false otherwise.

length

public float length()
length calculates the magnitude of this vector.

戻り値:
the length or magnitude of the vector.

lengthSquared

public float lengthSquared()
lengthSquared calculates the squared value of the magnitude of the vector.

戻り値:
the magnitude squared of the vector.

distanceSquared

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.
戻り値:
the distance squared between the two vectors.

distance

public float distance(Vector4f v)
distance calculates the distance between this vector and vector v.

パラメータ:
v - the second vector to determine the distance.
戻り値:
the distance between the two vectors.

mult

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.
戻り値:
the new vector.

mult

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.
戻り値:
product

multLocal

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.
戻り値:
this

multLocal

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.
戻り値:
this

multLocal

public Vector4f multLocal(float x,
                          float y,
                          float z,
                          float w)
multLocal multiplies this vector by 3 scalars internally, and returns a handle to this vector for easy chaining of calls.

パラメータ:
x -
y -
z -
w -
戻り値:
this

mult

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.
戻り値:
this

mult

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)
戻り値:
this

divide

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.
戻り値:
the result Vector.

divideLocal

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.
戻り値:
this

divide

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.
戻り値:
the result Vector.

divideLocal

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.
戻り値:
this

negate

public Vector4f negate()
negate returns the negative of this vector. All values are negated and set to a new vector.

戻り値:
the negated vector.

negateLocal

public Vector4f negateLocal()
negateLocal negates the internal values of this vector.

戻り値:
this.

subtract

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.
戻り値:
the result vector.

subtractLocal

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 subtract
戻り値:
this

subtract

public Vector4f subtract(Vector4f vec,
                         Vector4f result)
subtract

パラメータ:
vec - the vector to subtract from this
result - the vector to store the result in
戻り値:
result

subtract

public 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.
戻り値:
the result vector.

subtractLocal

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.
戻り値:
this

normalize

public Vector4f normalize()
normalize returns the unit vector of this vector.

戻り値:
unit vector of this vector.

normalizeLocal

public Vector4f normalizeLocal()
normalizeLocal makes this vector into a unit vector of itself.

戻り値:
this.

maxLocal

public void maxLocal(Vector4f other)
maxLocal computes the maximum value for each component in this and other vector. The result is stored in this vector.

パラメータ:
other -

minLocal

public void minLocal(Vector4f other)
minLocal computes the minimum value for each component in this and other vector. The result is stored in this vector.

パラメータ:
other -

zero

public Vector4f zero()
zero resets this vector's data to zero internally.


angleBetween

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 against
戻り値:
the angle in radians.

interpolate

public Vector4f interpolate(Vector4f finalVec,
                            float changeAmnt)
Sets this vector to the interpolation by changeAmnt from this to the finalVec this=(1-changeAmnt)*this + changeAmnt * finalVec

パラメータ:
finalVec - The final vector to interpolate towards
changeAmnt - An amount between 0.0 - 1.0 representing a precentage change from this towards finalVec

interpolate

public Vector4f interpolate(Vector4f beginVec,
                            Vector4f finalVec,
                            float changeAmnt)
Sets this vector to the interpolation by changeAmnt from beginVec to finalVec this=(1-changeAmnt)*beginVec + changeAmnt * finalVec

パラメータ:
beginVec - the beging vector (changeAmnt=0)
finalVec - The final vector to interpolate towards
changeAmnt - An amount between 0.0 - 1.0 representing a precentage change from beginVec towards finalVec

isValidVector

public static boolean isValidVector(Vector4f vector)
Check a vector... if it is null or its floats are NaN or infinite, return false. Else return true.

パラメータ:
vector - the vector to check
戻り値:
true or false as stated above.

clone

public Vector4f clone()
オーバーライド:
クラス java.lang.Object 内の clone

toArray

public float[] toArray(float[] floats)
Saves this Vector3f into the given float[] object.

パラメータ:
floats - The float[] to take this Vector3f. If null, a new float[3] is created.
戻り値:
The array, with X, Y, Z float values in that order

equals

public 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.

オーバーライド:
クラス java.lang.Object 内の equals
パラメータ:
o - the object to compare for equality
戻り値:
true if they are equal

hashCode

public 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.

オーバーライド:
クラス java.lang.Object 内の hashCode
戻り値:
the hash code value of this vector.

toString

public java.lang.String toString()
toString returns the string representation of this vector. The format is: org.jme.math.Vector3f [X=XX.XXXX, Y=YY.YYYY, Z=ZZ.ZZZZ, W=WW.WWWW]

オーバーライド:
クラス java.lang.Object 内の toString
戻り値:
the string representation of this vector.

write

public void write(JmeExporter e)
           throws java.io.IOException
定義:
インタフェース Savable 内の write
例外:
java.io.IOException

read

public void read(JmeImporter e)
          throws java.io.IOException
定義:
インタフェース Savable 内の read
例外:
java.io.IOException

getX

public float getX()

setX

public Vector4f setX(float x)

getY

public float getY()

setY

public Vector4f setY(float y)

getZ

public float getZ()

setZ

public Vector4f setZ(float z)

getW

public float getW()

setW

public Vector4f setW(float w)

get

public float get(int index)
パラメータ:
index -
戻り値:
x value if index == 0, y value if index == 1 or z value if index == 2
例外:
java.lang.IllegalArgumentException - if index is not one of 0, 1, 2.

set

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.