public class Vector2
extends java.lang.Object
Constructor and Description |
---|
Vector2()
This default constructor will initialize vector (0, 0);
|
Vector2(double x,
double y)
This constructor will initialize vector (X, Y) from the specified
X, Y coordinates.
|
Modifier and Type | Method and Description |
---|---|
Vector2 |
add(double s) |
Vector2 |
add(Vector2 v) |
Vector2 |
add(Vector2 v1,
Vector2 v2) |
void |
addX(double x)
This method will add specified value to X coordinate of the vector.
|
void |
addY(double y)
This method will add specified value to Y coordinate of the vector.
|
Vector2 |
ceil() |
Vector2 |
clamp(double minVal,
double maxVal) |
Vector2 |
clamp(Vector2 min,
Vector2 max)
This function assumes min < max, if this assumption isn't true it will not operate correctly
|
Vector2 |
clone() |
Vector2 |
copy(Vector2 v)
Set value of the vector from another vector.
|
double |
distanceTo(Vector2 v1) |
double |
distanceToSquared(Vector2 v) |
Vector2 |
divide(double s) |
Vector2 |
divide(Vector2 v) |
Vector2 |
divide(Vector2 v1,
Vector2 v2) |
double |
dot(Vector2 v)
Computes the dot product of the this vector and vector v1.
|
boolean |
equals(Vector2 v)
Returns true if all of the data members of Tuple2f t1 are equal to the
corresponding data members in this Tuple2f.
|
Vector2 |
floor() |
Vector2 |
fromArray(Float32Array array) |
Vector2 |
fromArray(Float32Array array,
int offset) |
double |
getComponent(int index) |
double |
getX()
get X coordinate from the vector
|
double |
getY()
get Y coordinate from the vector
|
boolean |
isZero() |
double |
length()
Returns the length of this vector.
|
double |
lengthSq()
Returns the squared length of this vector.
|
Vector2 |
lerp(Vector2 v1,
double alpha) |
Vector2 |
max(Vector2 v) |
Vector2 |
min(Vector2 v) |
Vector2 |
multiply(double s) |
Vector2 |
multiply(Vector2 v) |
Vector2 |
multiply(Vector2 v1,
Vector2 v2) |
Vector2 |
negate()
Negates the value of this vector in place.
|
Vector2 |
normalize()
Normalizes this vector in place.
|
Vector2 |
round() |
Vector2 |
roundToZero() |
Vector2 |
set(double x,
double y)
Set value of the vector to the specified (X, Y, Z) coordinates.
|
void |
setComponent(int index,
double value) |
Vector2 |
setLength(double l) |
void |
setX(double x)
This method sets X coordinate of the vector.
|
void |
setY(double y)
This method sets Y coordinate of the vector.
|
Vector2 |
sub(Vector2 v) |
Vector2 |
sub(Vector2 v1,
Vector2 v2) |
Float32Array |
toArray() |
Float32Array |
toArray(Float32Array array,
int offset) |
java.lang.String |
toString() |
public Vector2()
public Vector2(double x, double y)
x
- the X coordinatey
- the Y coordinatepublic double getX()
public double getY()
public void addX(double x)
x
- the X coordinatepublic void addY(double y)
y
- the Y coordinatepublic void setX(double x)
x
- the X coordinatepublic void setY(double y)
y
- the Y coordinatepublic Vector2 set(double x, double y)
x
- the X coordinatey
- the Y coordinatepublic void setComponent(int index, double value)
public double getComponent(int index)
public Vector2 copy(Vector2 v)
v
- the other vectorpublic Vector2 add(double s)
public Vector2 multiply(double s)
public Vector2 divide(double s)
public Vector2 clamp(Vector2 min, Vector2 max)
public Vector2 clamp(double minVal, double maxVal)
public Vector2 floor()
public Vector2 ceil()
public Vector2 round()
public Vector2 roundToZero()
public Vector2 negate()
public double dot(Vector2 v)
v
- the other vectorpublic double lengthSq()
public double length()
public Vector2 normalize()
public double distanceToSquared(Vector2 v)
public double distanceTo(Vector2 v1)
public Vector2 setLength(double l)
public boolean isZero()
public Vector2 fromArray(Float32Array array)
public Vector2 fromArray(Float32Array array, int offset)
public Float32Array toArray()
public Float32Array toArray(Float32Array array, int offset)
public Vector2 clone()
clone
in class java.lang.Object
public boolean equals(Vector2 v)
v
- the vector with which the comparison is madepublic java.lang.String toString()
toString
in class java.lang.Object