public final class Vector3
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Vector3 |
ONE |
static Vector3 |
UNIT_X |
static Vector3 |
UNIT_Y |
static Vector3 |
UNIT_Z |
static Vector3 |
ZERO |
Modifier and Type | Method and Description |
---|---|
Vector3 |
abs()
Returns a vector with the absolute values of the components of
this vector.
|
Vector3 |
add(double x,
double y,
double z)
Add another vector to this vector and return the result as a new vector.
|
Vector3 |
add(Vector3... others)
Add a list of vectors to this vector and return the
result as a new vector.
|
Vector3 |
add(Vector3 other)
Add another vector to this vector and return the result as a new vector.
|
static Vector3 |
at(double x,
double y,
double z) |
Vector3 |
ceil()
Rounds all components up.
|
Vector3 |
clampY(int min,
int max)
Clamp the Y component.
|
boolean |
containedWithin(Vector3 min,
Vector3 max)
Checks to see if a vector is contained with another.
|
Vector3 |
cross(Vector3 other)
Gets the cross product of this and another vector.
|
double |
distance(Vector3 other)
Get the distance between this vector and another vector.
|
double |
distanceSq(Vector3 other)
Get the distance between this vector and another vector, squared.
|
Vector3 |
divide(double n)
Perform scalar division and return a new vector.
|
Vector3 |
divide(double x,
double y,
double z)
Divide this vector by another vector on each component.
|
Vector3 |
divide(Vector3 other)
Divide this vector by another vector on each component.
|
double |
dot(Vector3 other)
Gets the dot product of this and another vector.
|
boolean |
equals(java.lang.Object obj) |
Vector3 |
floor()
Floors the values of all components.
|
Vector3 |
getMaximum(Vector3 v2)
Gets the maximum components of two vectors.
|
Vector3 |
getMinimum(Vector3 v2)
Gets the minimum components of two vectors.
|
double |
getX()
Get the X coordinate.
|
double |
getY()
Get the Y 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.
|
Vector3 |
multiply(double n)
Perform scalar multiplication and return a new vector.
|
Vector3 |
multiply(double x,
double y,
double z)
Multiply this vector by another vector on each component.
|
Vector3 |
multiply(Vector3... others)
Multiply this vector by zero or more vectors on each component.
|
Vector3 |
multiply(Vector3 other)
Multiply this vector by another vector on each component.
|
Vector3 |
normalize()
Get the normalized vector, which is the vector divided by its
length, as a new vector.
|
Vector3 |
round()
Rounds all components to the closest integer.
|
static java.util.Comparator<Vector3> |
sortByCoordsYzx()
Returns a comparator that sorts vectors first by Y, then Z, then X.
|
Vector3 |
subtract(double x,
double y,
double z)
Subtract another vector from this vector and return the result
as a new vector.
|
Vector3 |
subtract(Vector3... others)
Subtract a list of vectors from this vector and return the result
as a new vector.
|
Vector3 |
subtract(Vector3 other)
Subtract another vector from this vector and return the result
as a new vector.
|
BlockVector3 |
toBlockPoint()
Create a new
BlockVector from this vector. |
static BlockVector3 |
toBlockPoint(double x,
double y,
double z)
Create a new
BlockVector using the given components. |
java.lang.String |
toParserString()
Returns a string representation that is supported by the parser.
|
double |
toPitch()
Get this vector's pitch as used within the game.
|
java.lang.String |
toString() |
Vector2 |
toVector2()
Creates a 2D vector by dropping the Y component from this vector.
|
double |
toYaw()
Get this vector's yaw as used within the game.
|
Vector3 |
transform2D(double angle,
double aboutX,
double aboutZ,
double translateX,
double translateZ)
Perform a 2D transformation on this vector and return a new one.
|
Vector3 |
withX(double x)
Set the X coordinate.
|
Vector3 |
withY(double y)
Set the Y coordinate.
|
Vector3 |
withZ(double z)
Set the Z coordinate.
|
public static final Vector3 ZERO
public static final Vector3 UNIT_X
public static final Vector3 UNIT_Y
public static final Vector3 UNIT_Z
public static final Vector3 ONE
public static Vector3 at(double x, double y, double z)
public static java.util.Comparator<Vector3> sortByCoordsYzx()
Useful for sorting by chunk block storage order.
public double getX()
public Vector3 withX(double x)
x
- the new Xpublic double getY()
public Vector3 withY(double y)
y
- the new Ypublic double getZ()
public Vector3 withZ(double z)
z
- the new Zpublic Vector3 add(Vector3 other)
other
- the other vectorpublic Vector3 add(double x, double y, double z)
x
- the value to addy
- the value to addz
- the value to addpublic Vector3 add(Vector3... others)
others
- an array of vectorspublic Vector3 subtract(Vector3 other)
other
- the other vectorpublic Vector3 subtract(double x, double y, double z)
x
- the value to subtracty
- the value to subtractz
- the value to subtractpublic Vector3 subtract(Vector3... others)
others
- an array of vectorspublic Vector3 multiply(Vector3 other)
other
- the other vectorpublic Vector3 multiply(double x, double y, double z)
x
- the value to multiplyy
- the value to multiplyz
- the value to multiplypublic Vector3 multiply(Vector3... others)
others
- an array of vectorspublic Vector3 multiply(double n)
n
- the value to multiplypublic Vector3 divide(Vector3 other)
other
- the other vectorpublic Vector3 divide(double x, double y, double z)
x
- the value to divide byy
- the value to divide byz
- the value to divide bypublic Vector3 divide(double n)
n
- the value to divide bypublic double length()
public double lengthSq()
public double distance(Vector3 other)
other
- the other vectorpublic double distanceSq(Vector3 other)
other
- the other vectorpublic Vector3 normalize()
public double dot(Vector3 other)
other
- the other vectorpublic Vector3 cross(Vector3 other)
other
- the other vectorpublic boolean containedWithin(Vector3 min, Vector3 max)
min
- the minimum point (X, Y, and Z are the lowest)max
- the maximum point (X, Y, and Z are the lowest)public Vector3 clampY(int min, int max)
min
- the minimum valuemax
- the maximum valuepublic Vector3 floor()
public Vector3 ceil()
public Vector3 round()
Components < 0.5 are rounded down, otherwise up.
public Vector3 abs()
public Vector3 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 double toPitch()
public double toYaw()
public Vector3 getMinimum(Vector3 v2)
v2
- the second vectorpublic Vector3 getMaximum(Vector3 v2)
v2
- the second vectorpublic static BlockVector3 toBlockPoint(double x, double y, double z)
BlockVector
using the given components.x
- the X coordinatey
- the Y coordinatez
- the Z coordinateBlockVector
public BlockVector3 toBlockPoint()
BlockVector
from this vector.BlockVector
public Vector2 toVector2()
Vector2
public 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()