public final class BlockVector2
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<BlockVector2> |
COMPARING_GRID_ARRANGEMENT
A comparator for BlockVector2ds that orders the vectors by rows, with x as the
column and z as the row.
|
static BlockVector2 |
ONE |
static BlockVector2 |
UNIT_X |
static BlockVector2 |
UNIT_Z |
static BlockVector2 |
ZERO |
Modifier and Type | Method and Description |
---|---|
BlockVector2 |
abs()
Returns a vector with the absolute values of the components of
this vector.
|
BlockVector2 |
add(BlockVector2... others)
Add a list of vectors to this vector and return the
result as a new vector.
|
BlockVector2 |
add(BlockVector2 other)
Add another vector to this vector and return the result as a new vector.
|
BlockVector2 |
add(int x,
int z)
Add another vector to this vector and return the result as a new vector.
|
static BlockVector2 |
at(double x,
double z) |
static BlockVector2 |
at(int x,
int z) |
BlockVector2 |
ceil()
Rounds all components up.
|
boolean |
containedWithin(BlockVector2 min,
BlockVector2 max)
Checks to see if a vector is contained with another.
|
double |
distance(BlockVector2 other)
Get the distance between this vector and another vector.
|
int |
distanceSq(BlockVector2 other)
Get the distance between this vector and another vector, squared.
|
BlockVector2 |
divide(BlockVector2 other)
Divide this vector by another vector on each component.
|
BlockVector2 |
divide(int n)
Perform scalar division and return a new vector.
|
BlockVector2 |
divide(int x,
int z)
Divide this vector by another vector on each component.
|
int |
dot(BlockVector2 other)
Gets the dot product of this and another vector.
|
boolean |
equals(java.lang.Object obj) |
BlockVector2 |
floor()
Floors the values of all components.
|
int |
getBlockX()
Get the X coordinate.
|
int |
getBlockZ()
Get the Z coordinate.
|
BlockVector2 |
getMaximum(BlockVector2 v2)
Gets the maximum components of two vectors.
|
BlockVector2 |
getMinimum(BlockVector2 v2)
Gets the minimum components of two vectors.
|
int |
getX()
Get the X coordinate.
|
int |
getZ()
Get the Z coordinate.
|
int |
hashCode() |
double |
length()
Get the length of the vector.
|
int |
lengthSq()
Get the length, squared, of the vector.
|
BlockVector2 |
multiply(BlockVector2... others)
Multiply this vector by zero or more vectors on each component.
|
BlockVector2 |
multiply(BlockVector2 other)
Multiply this vector by another vector on each component.
|
BlockVector2 |
multiply(int n)
Perform scalar multiplication and return a new vector.
|
BlockVector2 |
multiply(int x,
int z)
Multiply this vector by another vector on each component.
|
BlockVector2 |
normalize()
Get the normalized vector, which is the vector divided by its
length, as a new vector.
|
BlockVector2 |
round()
Rounds all components to the closest integer.
|
BlockVector2 |
shr(int n)
Shift all components right by
n . |
BlockVector2 |
shr(int x,
int z)
Shift all components right.
|
BlockVector2 |
subtract(BlockVector2... others)
Subtract a list of vectors from this vector and return the result
as a new vector.
|
BlockVector2 |
subtract(BlockVector2 other)
Subtract another vector from this vector and return the result
as a new vector.
|
BlockVector2 |
subtract(int x,
int z)
Subtract another vector from this vector and return the result
as a new vector.
|
BlockVector3 |
toBlockVector3()
Creates a 3D vector by adding a zero Y component to this vector.
|
BlockVector3 |
toBlockVector3(int y)
Creates a 3D vector by adding the specified Y component to this vector.
|
java.lang.String |
toParserString()
Returns a string representation that is supported by the parser.
|
java.lang.String |
toString() |
Vector2 |
toVector2() |
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.
|
BlockVector2 |
transform2D(double angle,
double aboutX,
double aboutZ,
double translateX,
double translateZ)
Perform a 2D transformation on this vector and return a new one.
|
BlockVector2 |
withX(int x)
Set the X coordinate.
|
BlockVector2 |
withZ(int z)
Set the Z coordinate.
|
public static final BlockVector2 ZERO
public static final BlockVector2 UNIT_X
public static final BlockVector2 UNIT_Z
public static final BlockVector2 ONE
public static final java.util.Comparator<BlockVector2> COMPARING_GRID_ARRANGEMENT
For example, if x is the horizontal axis and z is the vertical axis, it sorts like so:
0123 4567 90ab cdef
public static BlockVector2 at(double x, double z)
public static BlockVector2 at(int x, int z)
public int getX()
public int getBlockX()
public BlockVector2 withX(int x)
x
- the new Xpublic int getZ()
public int getBlockZ()
public BlockVector2 withZ(int z)
z
- the new Zpublic BlockVector2 add(BlockVector2 other)
other
- the other vectorpublic BlockVector2 add(int x, int z)
x
- the value to addz
- the value to addpublic BlockVector2 add(BlockVector2... others)
others
- an array of vectorspublic BlockVector2 subtract(BlockVector2 other)
other
- the other vectorpublic BlockVector2 subtract(int x, int z)
x
- the value to subtractz
- the value to subtractpublic BlockVector2 subtract(BlockVector2... others)
others
- an array of vectorspublic BlockVector2 multiply(BlockVector2 other)
other
- the other vectorpublic BlockVector2 multiply(int x, int z)
x
- the value to multiplyz
- the value to multiplypublic BlockVector2 multiply(BlockVector2... others)
others
- an array of vectorspublic BlockVector2 multiply(int n)
n
- the value to multiplypublic BlockVector2 divide(BlockVector2 other)
other
- the other vectorpublic BlockVector2 divide(int x, int z)
x
- the value to divide byz
- the value to divide bypublic BlockVector2 divide(int n)
n
- the value to divide bypublic BlockVector2 shr(int x, int z)
x
- the value to shift x byz
- the value to shift z bypublic BlockVector2 shr(int n)
n
.n
- the value to shift bypublic double length()
public int lengthSq()
public double distance(BlockVector2 other)
other
- the other vectorpublic int distanceSq(BlockVector2 other)
other
- the other vectorpublic BlockVector2 normalize()
public int dot(BlockVector2 other)
other
- the other vectorpublic boolean containedWithin(BlockVector2 min, BlockVector2 max)
min
- the minimum point (X, Y, and Z are the lowest)max
- the maximum point (X, Y, and Z are the lowest)public BlockVector2 floor()
public BlockVector2 ceil()
public BlockVector2 round()
Components < 0.5 are rounded down, otherwise up.
public BlockVector2 abs()
public BlockVector2 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 BlockVector2 getMinimum(BlockVector2 v2)
v2
- the second vectorpublic BlockVector2 getMaximum(BlockVector2 v2)
v2
- the second vectorpublic Vector2 toVector2()
public Vector3 toVector3()
public Vector3 toVector3(double y)
y
- the Y componentpublic BlockVector3 toBlockVector3()
public BlockVector3 toBlockVector3(int 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()