| Modifier and Type | Field and Description |
|---|---|
| public static final Vector2 | |
| private static final long | |
| public static final Vector2 | |
| public float | x
the x-component of this vector |
| public static final Vector2 | |
| public float | y
the y-component of this vector |
| public static final Vector2 |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Vector2(float
The x-component x, float The y-component y)Constructs a vector with the given components |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Vector2 | |
| public Vector2 | Returns: This vector for chainingThe x-component x, float The y-component y)Adds the given components to this vector |
| public float | angle()
Deprecated
use
angleDeg() instead.
Returns: the angle in degrees of this vector (point) relative to the x-axis. |
| public float | angle(Vector2 reference)
Deprecated
use
angleDeg(Vector2) instead. Beware of the changes in returned angle to counter-clockwise and the
range.
Returns: the angle in degrees of this vector (point) relative to the given vector. |
| public float | |
| public float | |
| public static float | angleDeg(float x, float y)
Returns: the angle in degrees of this vector (point) relative to the x-axis. |
| public float | |
| public float | |
| public static float | angleRad(float x, float y)
Returns: the angle in radians of this vector (point) relative to the x-axis. |
| public Vector2 | clamp(float min, float max)
Implements com. Clamps this vector's length to given min and max values |
| public Vector2 | |
| public float | |
| public float | Returns: the cross productthe x-coordinate of the other vector x, float the y-coordinate of the other vector y)Calculates the 2D cross product between this and the given vector. |
| public static float | |
| public float | |
| public float | |
| public static float | |
| public float | |
| public float | dst(float
The x-component of the other vector x, float The y-component of the other vector y)Returns: the distance between this and the other vector |
| public static float | |
| public float | dst2(Vector2 v)
Implements com. This method is faster than |
| public float | dst2(float
The x-component of the other vector x, float The y-component of the other vector y)Returns: the squared distance between this and the other vector |
| public boolean | epsilonEquals(Vector2 other, float epsilon)
Implements com. Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. |
| public boolean | Returns: whether the vectors are the same.Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. |
| public boolean | Returns: true if vector are equal, otherwise falseother vector to compare other)Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing |
| public boolean | Returns: true if vector are equal, otherwise falsex component of the other vector to compare x, float y component of the other vector to compare y)Implements com. Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public Vector2 | Returns: this vector for chainingthe string. v)Sets this |
| public int | |
| public boolean | |
| public boolean | |
| public boolean | |
| public Vector2 | interpolate(Vector2 target, float alpha, Interpolation interpolation)
Implements com. Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method. |
| public boolean | |
| public boolean | |
| public boolean | isCollinearOpposite(Vector2 other, float epsilon)
Implements com.
|
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | isPerpendicular(Vector2 vector, float epsilon)
Implements com.
|
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public static float | |
| public float | |
| public static float | |
| public float | len2()
Implements com. This method is faster than |
| public Vector2 | lerp(Vector2 target, float alpha)
Implements com. Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. |
| public Vector2 | limit(float limit)
Implements com. Limits the length of this vector, based on the desired maximum length. |
| public Vector2 | limit2(float limit2)
Implements com. Limits the length of this vector, based on the desired maximum length squared. |
| public Vector2 | |
| public Vector2 | mulAdd(Vector2 vec, float scalar)
Implements com. First scale a supplied vector, then add it to this vector. |
| public Vector2 | mulAdd(Vector2 vec, Vector2 mulVec)
Implements com. First scale a supplied vector, then add it to this vector. |
| public Vector2 | |
| public Vector2 | rotate(float
the angle in degrees degrees)
Deprecated
use
rotateDeg(float) instead.
Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. |
| public Vector2 | rotate90(int dir)
Rotates the Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise. |
| public Vector2 | rotateAround(Vector2
center Vector2 reference, float the angle in degrees degrees)
Deprecated
use
rotateAroundDeg(Vector2, float) instead.
Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. |
| public Vector2 | rotateAroundDeg(Vector2
center Vector2 reference, float the angle in degrees degrees)Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. |
| public Vector2 | rotateAroundRad(Vector2
center Vector2 reference, float the angle in radians radians)Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. |
| public Vector2 | rotateDeg(float
the angle in degrees degrees)Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. |
| public Vector2 | rotateRad(float
the angle in radians radians)Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. |
| public Vector2 | scl(float scalar)
Implements com. Scales this vector by a scalar |
| public Vector2 | |
| public Vector2 | |
| public Vector2 | |
| public Vector2 | Returns: This vector for chainingThe x-component x, float The y-component y)Sets the components of this vector |
| public Vector2 | setAngle(float
The angle in degrees to set. degrees)
Deprecated
use
setAngleDeg(float) instead.
Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). |
| public Vector2 | setAngleDeg(float
The angle in degrees to set. degrees)Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). |
| public Vector2 | setAngleRad(float
The angle in radians to set. radians)Sets the angle of the vector in radians relative to the x-axis, towards the positive y-axis (typically counter-clockwise). |
| public Vector2 | setLength(float len)
Implements com. Sets the length of this vector. |
| public Vector2 | setLength2(float len2)
Implements com. Sets the length of this vector, based on the square of the desired length. |
| public Vector2 | setToRandomDirection()
Implements com. Sets this vector to the unit vector with a random direction |
| public Vector2 | |
| public Vector2 | sub(Vector2 v)
Implements com. Subtracts the given vector from this vector. |
| public Vector2 | Returns: This vector for chainingThe x-component of the other vector x, float The y-component of the other vector y)Subtracts the other vector from this vector. |
| public String | Returns: a string representation of this object.Overrides java. Converts this |
| One | back to summary |
|---|---|
| public static final Vector2 One | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| X | back to summary |
|---|---|
| public static final Vector2 X | |
| x | back to summary |
|---|---|
| public float x the x-component of this vector | |
| Y | back to summary |
|---|---|
| public static final Vector2 Y | |
| y | back to summary |
|---|---|
| public float y the y-component of this vector | |
| Zero | back to summary |
|---|---|
| public static final Vector2 Zero | |
| Vector2 | back to summary |
|---|---|
| public Vector2() Constructs a new vector at (0,0) | |
| Vector2 | back to summary |
|---|---|
| public Vector2(float x, float y) Constructs a vector with the given components
| |
| Vector2 | back to summary |
|---|---|
| public Vector2(Vector2 v) Constructs a vector from the given vector
| |
| add | back to summary |
|---|---|
| public Vector2 add(Vector2 v) Implements com. Doc from com. Adds the given vector to this vector
| |
| add | back to summary |
|---|---|
| public Vector2 add(float x, float y) Adds the given components to this vector
| |
| angle | back to summary |
|---|---|
| public float angle()
Deprecated use
| |
| angle | back to summary |
|---|---|
| public float angle(Vector2 reference)
Deprecated use
| |
| angleDeg | back to summary |
|---|---|
public float angleDeg()
| |
| angleDeg | back to summary |
|---|---|
public float angleDeg(Vector2 reference)
| |
| angleDeg | back to summary |
|---|---|
public static float angleDeg(float x, float y)
| |
| angleRad | back to summary |
|---|---|
public float angleRad()
| |
| angleRad | back to summary |
|---|---|
public float angleRad(Vector2 reference)
| |
| angleRad | back to summary |
|---|---|
public static float angleRad(float x, float y)
| |
| clamp | back to summary |
|---|---|
| public Vector2 clamp(float min, float max) Implements com. Doc from com. Clamps this vector's length to given min and max values
| |
| cpy | back to summary |
|---|---|
| public Vector2 cpy() Implements com.
| |
| crs | back to summary |
|---|---|
| public float crs(Vector2 v) Calculates the 2D cross product between this and the given vector.
| |
| crs | back to summary |
|---|---|
| public float crs(float x, float y) Calculates the 2D cross product between this and the given vector.
| |
| dot | back to summary |
|---|---|
| public static float dot(float x1, float y1, float x2, float y2) | |
| dot | back to summary |
|---|---|
| public float dot(Vector2 v) Implements com.
| |
| dot | back to summary |
|---|---|
| public float dot(float ox, float oy) | |
| dst | back to summary |
|---|---|
| public static float dst(float x1, float y1, float x2, float y2) | |
| dst | back to summary |
|---|---|
| public float dst(Vector2 v) Implements com.
| |
| dst | back to summary |
|---|---|
public float dst(float x, float y)
| |
| dst2 | back to summary |
|---|---|
| public static float dst2(float x1, float y1, float x2, float y2) | |
| dst2 | back to summary |
|---|---|
| public float dst2(Vector2 v) Implements com. Doc from com. This method is faster than
| |
| dst2 | back to summary |
|---|---|
public float dst2(float x, float y)
| |
| epsilonEquals | back to summary |
|---|---|
| public boolean epsilonEquals(Vector2 other, float epsilon) Implements com. Doc from com. Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
| |
| epsilonEquals | back to summary |
|---|---|
| public boolean epsilonEquals(float x, float y, float epsilon) Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing.
| |
| epsilonEquals | back to summary |
|---|---|
| public boolean epsilonEquals(final Vector2 other) Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
| |
| epsilonEquals | back to summary |
|---|---|
| public boolean epsilonEquals(float x, float y) Implements com. Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| fromString | back to summary |
|---|---|
| public Vector2 fromString(String v) Sets this | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| hasOppositeDirection | back to summary |
|---|---|
| public boolean hasOppositeDirection(Vector2 vector) Implements com.
| |
| hasSameDirection | back to summary |
|---|---|
| public boolean hasSameDirection(Vector2 vector) Implements com.
| |
| idt | back to summary |
|---|---|
| public boolean idt(final Vector2 vector) Returns true if this vector and the vector parameter have identical components.
| |
| interpolate | back to summary |
|---|---|
| public Vector2 interpolate(Vector2 target, float alpha, Interpolation interpolation) Implements com. Doc from com. Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation method. the result is stored in this vector.
| |
| isCollinear | back to summary |
|---|---|
| public boolean isCollinear(Vector2 other, float epsilon) Implements com.
| |
| isCollinear | back to summary |
|---|---|
| public boolean isCollinear(Vector2 other) Implements com.
| |
| isCollinearOpposite | back to summary |
|---|---|
| public boolean isCollinearOpposite(Vector2 other, float epsilon) Implements com.
| |
| isCollinearOpposite | back to summary |
|---|---|
| public boolean isCollinearOpposite(Vector2 other) Implements com.
| |
| isOnLine | back to summary |
|---|---|
| public boolean isOnLine(Vector2 other) Implements com.
| |
| isOnLine | back to summary |
|---|---|
| public boolean isOnLine(Vector2 other, float epsilon) Implements com.
| |
| isPerpendicular | back to summary |
|---|---|
| public boolean isPerpendicular(Vector2 vector) Implements com.
| |
| isPerpendicular | back to summary |
|---|---|
| public boolean isPerpendicular(Vector2 vector, float epsilon) Implements com.
| |
| isUnit | back to summary |
|---|---|
| public boolean isUnit() Implements com.
| |
| isUnit | back to summary |
|---|---|
| public boolean isUnit(final float margin) Implements com.
| |
| isZero | back to summary |
|---|---|
| public boolean isZero() Implements com.
| |
| isZero | back to summary |
|---|---|
| public boolean isZero(final float margin) Implements com.
| |
| len | back to summary |
|---|---|
| public static float len(float x, float y) | |
| len | back to summary |
|---|---|
| public float len() Implements com.
| |
| len2 | back to summary |
|---|---|
| public static float len2(float x, float y) | |
| len2 | back to summary |
|---|---|
| public float len2() Implements com. Doc from com. This method is faster than
| |
| lerp | back to summary |
|---|---|
| public Vector2 lerp(Vector2 target, float alpha) Implements com. Doc from com. Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector.
| |
| limit | back to summary |
|---|---|
| public Vector2 limit(float limit) Implements com. Doc from com. Limits the length of this vector, based on the desired maximum length.
| |
| limit2 | back to summary |
|---|---|
| public Vector2 limit2(float limit2) Implements com. Doc from com. Limits the length of this vector, based on the desired maximum length squared. This method is slightly faster than limit().
| |
| mul | back to summary |
|---|---|
| public Vector2 mul(Matrix3 mat) Left-multiplies this vector by the given matrix | |
| mulAdd | back to summary |
|---|---|
| public Vector2 mulAdd(Vector2 vec, float scalar) Implements com. Doc from com. First scale a supplied vector, then add it to this vector.
| |
| mulAdd | back to summary |
|---|---|
| public Vector2 mulAdd(Vector2 vec, Vector2 mulVec) Implements com. Doc from com. First scale a supplied vector, then add it to this vector.
| |
| nor | back to summary |
|---|---|
| public Vector2 nor() Implements com. Doc from com. Normalizes this vector. Does nothing if it is zero.
| |
| rotate | back to summary |
|---|---|
| public Vector2 rotate(float degrees)
Deprecated use Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up.
| |
| rotate90 | back to summary |
|---|---|
| public Vector2 rotate90(int dir) Rotates the Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise. | |
| rotateAround | back to summary |
|---|---|
| public Vector2 rotateAround(Vector2 reference, float degrees)
Deprecated use Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up.
| |
| rotateAroundDeg | back to summary |
|---|---|
| public Vector2 rotateAroundDeg(Vector2 reference, float degrees) Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up.
| |
| rotateAroundRad | back to summary |
|---|---|
| public Vector2 rotateAroundRad(Vector2 reference, float radians) Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up.
| |
| rotateDeg | back to summary |
|---|---|
| public Vector2 rotateDeg(float degrees) Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up.
| |
| rotateRad | back to summary |
|---|---|
| public Vector2 rotateRad(float radians) Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up.
| |
| scl | back to summary |
|---|---|
| public Vector2 scl(float scalar) Implements com. Doc from com. Scales this vector by a scalar
| |
| scl | back to summary |
|---|---|
| public Vector2 scl(float x, float y) Multiplies this vector by a scalar
| |
| scl | back to summary |
|---|---|
| public Vector2 scl(Vector2 v) Implements com. Doc from com. Scales this vector by another vector
| |
| set | back to summary |
|---|---|
| public Vector2 set(Vector2 v) Implements com. Doc from com. Sets this vector from the given vector
| |
| set | back to summary |
|---|---|
| public Vector2 set(float x, float y) Sets the components of this vector
| |
| setAngle | back to summary |
|---|---|
| public Vector2 setAngle(float degrees)
Deprecated use Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise).
| |
| setAngleDeg | back to summary |
|---|---|
| public Vector2 setAngleDeg(float degrees) Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise).
| |
| setAngleRad | back to summary |
|---|---|
| public Vector2 setAngleRad(float radians) Sets the angle of the vector in radians relative to the x-axis, towards the positive y-axis (typically counter-clockwise).
| |
| setLength | back to summary |
|---|---|
| public Vector2 setLength(float len) Implements com. Doc from com. Sets the length of this vector. Does nothing if this vector is zero.
| |
| setLength2 | back to summary |
|---|---|
| public Vector2 setLength2(float len2) Implements com. Doc from com. Sets the length of this vector, based on the square of the desired length. Does nothing if this vector is zero. This method is slightly faster than setLength().
| |
| setToRandomDirection | back to summary |
|---|---|
| public Vector2 setToRandomDirection() Implements com. Doc from com. Sets this vector to the unit vector with a random direction
| |
| setZero | back to summary |
|---|---|
| public Vector2 setZero() Implements com. Doc from com. Sets the components of this vector to 0
| |
| sub | back to summary |
|---|---|
| public Vector2 sub(Vector2 v) Implements com. Doc from com. Subtracts the given vector from this vector.
| |
| sub | back to summary |
|---|---|
| public Vector2 sub(float x, float y) Subtracts the other vector from this vector.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Converts this | |