|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.math.Vector2
public class Vector2
Encapsulates a 2D vector. Allows chaining methods by returning a reference to itself
Field Summary | |
---|---|
static Vector2 |
tmp
Static temporary vector. |
static Vector2 |
tmp2
Static temporary vector. |
static Vector2 |
tmp3
Static temporary vector. |
float |
x
the x-component of this vector |
static Vector2 |
X
|
float |
y
the y-component of this vector |
static Vector2 |
Y
|
static Vector2 |
Zero
|
Constructor Summary | |
---|---|
Vector2()
Constructs a new vector at (0,0) |
|
Vector2(float x,
float y)
Constructs a vector with the given components |
|
Vector2(Vector2 v)
Constructs a vector from the given vector |
Method Summary | |
---|---|
Vector2 |
add(float x,
float y)
Adds the given components to this vector |
Vector2 |
add(Vector2 v)
Adds the given vector to this vector |
float |
angle()
|
Vector2 |
cpy()
|
float |
crs(float x,
float y)
Calculates the 2D cross product between this and the given vector. |
float |
crs(Vector2 v)
Calculates the 2D cross product between this and the given vector. |
Vector2 |
div(float value)
|
Vector2 |
div(float vx,
float vy)
|
Vector2 |
div(Vector2 other)
|
float |
dot(Vector2 v)
|
float |
dst(float x,
float y)
|
float |
dst(Vector2 v)
|
float |
dst2(float x,
float y)
|
float |
dst2(Vector2 v)
|
boolean |
epsilonEquals(Vector2 obj,
float epsilon)
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. |
boolean |
equals(java.lang.Object obj)
|
int |
hashCode()
|
float |
len()
|
float |
len2()
|
Vector2 |
lerp(Vector2 target,
float alpha)
Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. |
Vector2 |
mul(float scalar)
Multiplies this vector by a scalar |
Vector2 |
mul(float x,
float y)
Multiplies this vector by a scalar |
Vector2 |
mul(Matrix3 mat)
Multiplies this vector by the given matrix |
Vector2 |
nor()
Normalizes this vector |
Vector2 |
rotate(float degrees)
Rotates the Vector2 by the given angle, counter-clockwise. |
Vector2 |
set(float x,
float y)
Sets the components of this vector |
Vector2 |
set(Vector2 v)
Sets this vector from the given vector |
void |
setAngle(float angle)
Sets the angle of the vector. |
Vector2 |
sub(float x,
float y)
Substracts the other vector from this vector. |
Vector2 |
sub(Vector2 v)
Substracts the given vector from this vector. |
Vector2 |
tmp()
NEVER EVER SAVE THIS REFERENCE! Do not use this unless you are aware of the side-effects, e.g. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Vector2 tmp
tmp()
public static final Vector2 tmp2
tmp()
public static final Vector2 tmp3
tmp()
public static final Vector2 X
public static final Vector2 Y
public static final Vector2 Zero
public float x
public float y
Constructor Detail |
---|
public Vector2()
public Vector2(float x, float y)
x
- The x-componenty
- The y-componentpublic Vector2(Vector2 v)
v
- The vectorMethod Detail |
---|
public Vector2 cpy()
public float len()
public float len2()
public Vector2 set(Vector2 v)
v
- The vector
public Vector2 set(float x, float y)
x
- The x-componenty
- The y-component
public Vector2 sub(Vector2 v)
v
- The vector
public Vector2 nor()
public Vector2 add(Vector2 v)
v
- The vector
public Vector2 add(float x, float y)
x
- The x-componenty
- The y-component
public float dot(Vector2 v)
v
- The other vector
public Vector2 mul(float scalar)
scalar
- The scalar
public Vector2 mul(float x, float y)
public Vector2 div(float value)
public Vector2 div(float vx, float vy)
public Vector2 div(Vector2 other)
public float dst(Vector2 v)
v
- The other vector
public float dst(float x, float y)
x
- The x-component of the other vectory
- The y-component of the other vector
public float dst2(Vector2 v)
v
- The other vector
public float dst2(float x, float y)
x
- The x-component of the other vectory
- The y-component of the other vector
public java.lang.String toString()
toString
in class java.lang.Object
public Vector2 sub(float x, float y)
x
- The x-component of the other vectory
- The y-component of the other vector
public Vector2 tmp()
public Vector2 mul(Matrix3 mat)
mat
- the matrix
public float crs(Vector2 v)
v
- the other vector
public float crs(float x, float y)
x
- the x-coordinate of the other vectory
- the y-coordinate of the other vector
public float angle()
public void setAngle(float angle)
angle
- The angle to set.public Vector2 rotate(float degrees)
degrees
- the angle in degreespublic Vector2 lerp(Vector2 target, float alpha)
target
- The target vectoralpha
- The interpolation coefficient
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean epsilonEquals(Vector2 obj, float epsilon)
obj
- epsilon
-
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |