public final class Vector2
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Vector2 |
ONE |
static Vector2 |
UNIT_X |
static Vector2 |
UNIT_Z |
static Vector2 |
ZERO |
Modifier and Type | Method and Description |
---|---|
Vector2 |
abs()
Returns a vector with the absolute values of the components of
this vector.
|
Vector2 |
add(double x,
double z)
Add another vector to this vector and return the result as a new vector.
|
Vector2 |
add(Vector2... others)
Add a list of vectors to this vector and return the
result as a new vector.
|
Vector2 |
add(Vector2 other)
Add another vector to this vector and return the result as a new vector.
|
static Vector2 |
at(double x,
double z) |
Vector2 |
ceil()
Rounds all components up.
|
boolean |
containedWithin(Vector2 min,
Vector2 max)
Checks to see if a vector is contained with another.
|
double |
distance(Vector2 other)
Get the distance between this vector and another vector.
|
double |
distanceSq(Vector2 other)
Get the distance between this vector and another vector, squared.
|
Vector2 |
divide(double n)
Perform scalar division and return a new vector.
|
Vector2 |
divide(double x,
double z)
Divide this vector by another vector on each component.
|
Vector2 |
divide(Vector2 other)
Divide this vector by another vector on each component.
|
double |
dot(Vector2 other)
Gets the dot product of this and another vector.
|
boolean |
equals(java.lang.Object obj) |
Vector2 |
floor()
Floors the values of all components.
|
Vector2 |
getMaximum(Vector2 v2)
Gets the maximum components of two vectors.
|
Vector2 |
getMinimum(Vector2 v2)
Gets the minimum components of two vectors.
|
double |
getX()
Get the X coordinate.
|
double |
getZ()
Get the Z coordinate.
|
int |
hashCode() |
double |
length()
Get the length of the vector.
|
double |
lengthSq()
Get the length, squared, of the vector.
|
Vector2 |
multiply(double n)
Perform scalar multiplication and return a new vector.
|
Vector2 |
multiply(double x,
double z)
Multiply this vector by another vector on each component.
|
Vector2 |
multiply(Vector2... others)
Multiply this vector by zero or more vectors on each component.
|
Vector2 |
multiply(Vector2 other)
Multiply this vector by another vector on each component.
|
Vector2 |
normalize()
Get the normalized vector, which is the vector divided by its
length, as a new vector.
|
Vector2 |
round()
Rounds all components to the closest integer.
|
Vector2 |
subtract(double x,
double z)
Subtract another vector from this vector and return the result
as a new vector.
|
Vector2 |
subtract(Vector2... others)
Subtract a list of vectors from this vector and return the result
as a new vector.
|
Vector2 |
subtract(Vector2 other)
Subtract another vector from this vector and return the result
as a new vector.
|
BlockVector2 |
toBlockPoint()
Create a new
BlockVector2 from this vector. |
static BlockVector2 |
toBlockPoint(double x,
double z) |
java.lang.String |
toParserString()
Returns a string representation that is supported by the parser.
|
java.lang.String |
toString() |
Vector3 |
toVector3()
Creates a 3D vector by adding a zero Y component to this vector.
|
Vector3 |
toVector3(double y)
Creates a 3D vector by adding the specified Y component to this vector.
|
Vector2 |
transform2D(double angle,
double aboutX,
double aboutZ,
double translateX,
double translateZ)
Perform a 2D transformation on this vector and return a new one.
|
Vector2 |
withX(double x)
Set the X coordinate.
|
Vector2 |
withZ(double z)
Set the Z coordinate.
|
public static final Vector2 ZERO
public static final Vector2 UNIT_X
public static final Vector2 UNIT_Z
public static final Vector2 ONE
public static Vector2 at(double x, double z)
public double getX()
public Vector2 withX(double x)
x
- the new Xpublic double getZ()
public Vector2 withZ(double z)
z
- the new Zpublic Vector2 add(Vector2 other)
other
- the other vectorpublic Vector2 add(double x, double z)
x
- the value to addz
- the value to addpublic Vector2 add(Vector2... others)
others
- an array of vectorspublic Vector2 subtract(Vector2 other)
other
- the other vectorpublic Vector2 subtract(double x, double z)
x
- the value to subtractz
- the value to subtractpublic Vector2 subtract(Vector2... others)
others
- an array of vectorspublic Vector2 multiply(Vector2 other)
other
- the other vectorpublic Vector2 multiply(double x, double z)
x
- the value to multiplyz
- the value to multiplypublic Vector2 multiply(Vector2... others)
others
- an array of vectorspublic Vector2 multiply(double n)
n
- the value to multiplypublic Vector2 divide(Vector2 other)
other
- the other vectorpublic Vector2 divide(double x, double z)
x
- the value to divide byz
- the value to divide bypublic Vector2 divide(double n)
n
- the value to divide bypublic double length()
public double lengthSq()
public double distance(Vector2 other)
other
- the other vectorpublic double distanceSq(Vector2 other)
other
- the other vectorpublic Vector2 normalize()
public double dot(Vector2 other)
other
- the other vectorpublic boolean containedWithin(Vector2 min, Vector2 max)
min
- the minimum point (X, Y, and Z are the lowest)max
- the maximum point (X, Y, and Z are the lowest)public Vector2 floor()
public Vector2 ceil()
public Vector2 round()
Components < 0.5 are rounded down, otherwise up.
public Vector2 abs()
public Vector2 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ)
angle
- in degreesaboutX
- about which x coordinate to rotateaboutZ
- about which z coordinate to rotatetranslateX
- what to add after rotationtranslateZ
- what to add after rotationanother method to transform vectors
public Vector2 getMinimum(Vector2 v2)
v2
- the second vectorpublic Vector2 getMaximum(Vector2 v2)
v2
- the second vectorpublic static BlockVector2 toBlockPoint(double x, double z)
public BlockVector2 toBlockPoint()
BlockVector2
from this vector.BlockVector2
public Vector3 toVector3()
public Vector3 toVector3(double y)
y
- the Y componentpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toParserString()