com.jme3.math
クラス Vector2f

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

public final class Vector2f
extends java.lang.Object
implements Savable, java.lang.Cloneable, java.io.Serializable

Vector2f defines a Vector for a two float value vector.

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

フィールドの概要
static Vector2f UNIT_XY
           
 float x
          the x value of the vector.
 float y
          the y value of the vector.
static Vector2f ZERO
           
 
コンストラクタの概要
Vector2f()
          Creates a Vector2f with x and y set to 0.
Vector2f(float x, float y)
          Creates a Vector2f with the given initial x and y values.
Vector2f(Vector2f vector2f)
          Creates a new Vector2f that contains the passed vector's information
 
メソッドの概要
 Vector2f add(Vector2f vec)
          add adds a provided vector to this vector creating a resultant vector which is returned.
 Vector2f add(Vector2f vec, Vector2f result)
          add adds this vector by vec and stores the result in result.
 Vector2f addLocal(float addX, float addY)
          addLocal adds the provided values to this vector internally, and returns a handle to this vector for easy chaining of calls.
 Vector2f addLocal(Vector2f vec)
          addLocal adds a provided vector to this vector internally, and returns a handle to this vector for easy chaining of calls.
 float angleBetween(Vector2f otherVector)
          angleBetween returns (in radians) the angle required to rotate a ray represented by this vector to lie colinear to a ray described by the given vector.
 Vector2f clone()
           
 Vector3f cross(Vector2f v)
          cross calculates the cross product of this vector with a parameter vector v.
 float determinant(Vector2f v)
           
 float distance(Vector2f v)
          distance calculates the distance between this vector and vector v.
 float distanceSquared(float otherX, float otherY)
          distanceSquared calculates the distance squared between this vector and vector v.
 float distanceSquared(Vector2f v)
          distanceSquared calculates the distance squared between this vector and vector v.
 Vector2f divide(float scalar)
          divide divides the values of this vector by a scalar and returns the result.
 Vector2f divideLocal(float scalar)
          divideLocal divides this vector by a scalar internally, and returns a handle to this vector for easy chaining of calls.
 float dot(Vector2f 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 getAngle()
          getAngle returns (in radians) the angle represented by this Vector2f as expressed by a conversion from rectangular coordinates (xy) to polar coordinates (r, theta).
 float getX()
           
 float getY()
           
 int hashCode()
          hashCode returns a unique code for this vector object based on it's values.
 Vector2f interpolate(Vector2f finalVec, float changeAmnt)
          Sets this vector to the interpolation by changeAmnt from this to the finalVec this=(1-changeAmnt)*this + changeAmnt * finalVec
 Vector2f interpolate(Vector2f beginVec, Vector2f finalVec, float changeAmnt)
          Sets this vector to the interpolation by changeAmnt from beginVec to finalVec this=(1-changeAmnt)*beginVec + changeAmnt * finalVec
static boolean isValidVector(Vector2f 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.
 Vector2f mult(float scalar)
          mult multiplies this vector by a scalar.
 Vector2f mult(float scalar, Vector2f product)
          Multiplies this Vector2f's x and y by the scalar and stores the result in product.
 Vector2f multLocal(float scalar)
          multLocal multiplies this vector by a scalar internally, and returns a handle to this vector for easy chaining of calls.
 Vector2f multLocal(Vector2f vec)
          multLocal multiplies a provided vector to this vector internally, and returns a handle to this vector for easy chaining of calls.
 Vector2f negate()
          negate returns the negative of this vector.
 Vector2f negateLocal()
          negateLocal negates the internal values of this vector.
 Vector2f normalize()
          normalize returns the unit vector of this vector.
 Vector2f normalizeLocal()
          normalizeLocal makes this vector into a unit vector of itself.
 void read(JmeImporter e)
           
 void readExternal(java.io.ObjectInput in)
          Used with serialization.
 void rotateAroundOrigin(float angle, boolean cw)
           
 Vector2f set(float x, float y)
          set the x and y values of the vector
 Vector2f set(Vector2f vec)
          set the x and y values of the vector from another vector
 Vector2f setX(float x)
           
 Vector2f setY(float y)
           
 float smallestAngleBetween(Vector2f otherVector)
          smallestAngleBetween returns (in radians) the minimum angle between two vectors.
 Vector2f subtract(float valX, float valY)
          subtract subtracts the given x,y values from those of this vector creating a new vector object.
 Vector2f subtract(Vector2f vec)
          subtract subtracts the values of a given vector from those of this vector creating a new vector object.
 Vector2f subtract(Vector2f vec, Vector2f store)
          subtract subtracts the values of a given vector from those of this vector storing the result in the given vector object.
 Vector2f subtractLocal(float valX, float valY)
          subtractLocal subtracts the provided values from this vector internally, and returns a handle to this vector for easy chaining of calls.
 Vector2f subtractLocal(Vector2f 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 Vector2f into the given float[] object.
 java.lang.String toString()
          toString returns the string representation of this vector object.
 void write(JmeExporter e)
           
 void writeExternal(java.io.ObjectOutput out)
          Used with serialization.
 Vector2f zero()
          zero resets this vector's data to zero internally.
 
クラス java.lang.Object から継承されたメソッド
getClass, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

ZERO

public static final Vector2f ZERO

UNIT_XY

public static final Vector2f UNIT_XY

x

public float x
the x value of the vector.


y

public float y
the y value of the vector.

コンストラクタの詳細

Vector2f

public Vector2f(float x,
                float y)
Creates a Vector2f with the given initial x and y values.

パラメータ:
x - The x value of this Vector2f.
y - The y value of this Vector2f.

Vector2f

public Vector2f()
Creates a Vector2f with x and y set to 0. Equivalent to Vector2f(0,0).


Vector2f

public Vector2f(Vector2f vector2f)
Creates a new Vector2f that contains the passed vector's information

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

set

public Vector2f set(float x,
                    float y)
set the x and y values of the vector

パラメータ:
x - the x value of the vector.
y - the y value of the vector.
戻り値:
this vector

set

public Vector2f set(Vector2f vec)
set the x and y values of the vector from another vector

パラメータ:
vec - the vector to copy from
戻り値:
this vector

add

public Vector2f add(Vector2f 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.

addLocal

public Vector2f addLocal(Vector2f 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

addLocal

public Vector2f addLocal(float addX,
                         float addY)
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
戻り値:
this

add

public Vector2f add(Vector2f vec,
                    Vector2f result)
add adds this vector by vec and stores the result in result.

パラメータ:
vec - The vector to add.
result - The vector to store the result in.
戻り値:
The result vector, after adding.

dot

public float dot(Vector2f 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.

cross

public Vector3f cross(Vector2f 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.
戻り値:
the cross product vector.

determinant

public float determinant(Vector2f v)

interpolate

public Vector2f interpolate(Vector2f 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 percentage change from this towards finalVec

interpolate

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

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

isValidVector

public static boolean isValidVector(Vector2f 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.

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(Vector2f 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.

distanceSquared

public float distanceSquared(float otherX,
                             float otherY)
distanceSquared calculates the distance squared between this vector and vector v.

パラメータ:
otherX - The X coordinate of the v vector
otherY - The Y coordinate of the v vector
戻り値:
the distance squared between the two vectors.

distance

public float distance(Vector2f 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 Vector2f 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.

multLocal

public Vector2f 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 Vector2f multLocal(Vector2f 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 Vector2f mult(float scalar,
                     Vector2f product)
Multiplies this Vector2f's x and y by the scalar and stores the result in product. The result is returned for chaining. Similar to product=this*scalar;

パラメータ:
scalar - The scalar to multiply by.
product - The vector2f to store the result in.
戻り値:
product, after multiplication.

divide

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

negate

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

戻り値:
the negated vector.

negateLocal

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

戻り値:
this.

subtract

public Vector2f subtract(Vector2f 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, an exception is thrown.

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

subtract

public Vector2f subtract(Vector2f vec,
                         Vector2f store)
subtract subtracts the values of a given vector from those of this vector storing the result in the given vector object. If the provided vector is null, an exception is thrown.

パラメータ:
vec - the vector to subtract from this vector.
store - the vector to store the result in. It is safe for this to be the same as vec. If null, a new vector is created.
戻り値:
the result vector.

subtract

public Vector2f subtract(float valX,
                         float valY)
subtract subtracts the given x,y values from those of this vector creating a new vector object.

パラメータ:
valX - value to subtract from x
valY - value to subtract from y
戻り値:
this

subtractLocal

public Vector2f subtractLocal(Vector2f 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

subtractLocal

public Vector2f subtractLocal(float valX,
                              float valY)
subtractLocal subtracts the provided values from this vector internally, and returns a handle to this vector for easy chaining of calls.

パラメータ:
valX - value to subtract from x
valY - value to subtract from y
戻り値:
this

normalize

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

戻り値:
unit vector of this vector.

normalizeLocal

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

戻り値:
this.

smallestAngleBetween

public float smallestAngleBetween(Vector2f otherVector)
smallestAngleBetween returns (in radians) the minimum 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.

angleBetween

public float angleBetween(Vector2f otherVector)
angleBetween returns (in radians) the angle required to rotate a ray represented by this vector to lie colinear to a ray described by the given vector. It is assumed that both this vector and the given vector are unit vectors (iow, normalized).

パラメータ:
otherVector - the "destination" unit vector
戻り値:
the angle in radians.

getX

public float getX()

setX

public Vector2f setX(float x)

getY

public float getY()

setY

public Vector2f setY(float y)

getAngle

public float getAngle()
getAngle returns (in radians) the angle represented by this Vector2f as expressed by a conversion from rectangular coordinates (xy) to polar coordinates (r, theta).

戻り値:
the angle in radians. [-pi, pi)

zero

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


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.

clone

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

toArray

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

パラメータ:
floats - The float[] to take this Vector2f. If null, a new float[2] is created.
戻り値:
The array, with X, Y 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 and y values.

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

toString

public java.lang.String toString()
toString returns the string representation of this vector object. The format of the string is such: com.jme.math.Vector2f [X=XX.XXXX, Y=YY.YYYY]

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

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Used with serialization. Not to be called manually.

パラメータ:
in - ObjectInput
例外:
java.io.IOException
java.lang.ClassNotFoundException
関連項目:
Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Used with serialization. Not to be called manually.

パラメータ:
out - ObjectOutput
例外:
java.io.IOException
関連項目:
Externalizable

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

rotateAroundOrigin

public void rotateAroundOrigin(float angle,
                               boolean cw)