public class Vector2D extends Object
| Modifier and Type | Field and Description |
|---|---|
static Vector2D |
ONE |
static Vector2D |
UNIT_X |
static Vector2D |
UNIT_Z |
protected double |
x |
protected double |
z |
static Vector2D |
ZERO |
| Constructor and Description |
|---|
Vector2D()
Construct the Vector2D object.
|
Vector2D(double x,
double z)
Construct the Vector2D object.
|
Vector2D(float x,
float z)
Construct the Vector2D object.
|
Vector2D(int x,
int z)
Construct the Vector2D object.
|
Vector2D(Vector2D pt)
Construct the Vector2D object.
|
| Modifier and Type | Method and Description |
|---|---|
Vector2D |
add(double x,
double z)
Adds two points.
|
Vector2D |
add(int x,
int z)
Adds two points.
|
Vector2D |
add(Vector2D... others)
Adds points.
|
Vector2D |
add(Vector2D other)
Adds two points.
|
Vector2D |
ceil()
Rounds all components up.
|
boolean |
containedWithin(Vector2D min,
Vector2D max)
Checks to see if a vector is contained with another.
|
boolean |
containedWithinBlock(Vector2D min,
Vector2D max)
Checks to see if a vector is contained with another.
|
double |
distance(Vector2D pt)
Get the distance away from a point.
|
double |
distanceSq(Vector2D pt)
Get the distance away from a point, squared.
|
Vector2D |
divide(double n)
Scalar division.
|
Vector2D |
divide(double x,
double z)
Component-wise division
|
Vector2D |
divide(float n)
Scalar division.
|
Vector2D |
divide(int n)
Scalar division.
|
Vector2D |
divide(int x,
int z)
Component-wise division
|
Vector2D |
divide(Vector2D other)
Component-wise division
|
double |
dot(Vector2D other)
Gets the dot product of this and another vector.
|
boolean |
equals(Object obj)
Checks if another object is equivalent.
|
Vector2D |
floor()
Rounds all components down.
|
int |
getBlockX() |
int |
getBlockZ() |
static Vector2D |
getMaximum(Vector2D v1,
Vector2D v2)
Gets the maximum components of two vectors.
|
static Vector2D |
getMinimum(Vector2D v1,
Vector2D v2)
Gets the minimum components of two vectors.
|
double |
getX() |
double |
getZ() |
int |
hashCode()
Gets the hash code.
|
boolean |
isCollinearWith(Vector2D other) |
double |
length()
Get the length of the vector.
|
double |
lengthSq()
Get the length^2 of the vector.
|
Vector2D |
multiply(double n)
Scalar multiplication.
|
Vector2D |
multiply(double x,
double z)
Component-wise multiplication
|
Vector2D |
multiply(float n)
Scalar multiplication.
|
Vector2D |
multiply(int n)
Scalar multiplication.
|
Vector2D |
multiply(int x,
int z)
Component-wise multiplication
|
Vector2D |
multiply(Vector2D... others)
Component-wise multiplication
|
Vector2D |
multiply(Vector2D other)
Component-wise multiplication
|
Vector2D |
normalize()
Get the normalized vector.
|
Vector2D |
positive()
Returns a vector with the absolute values of the components of this vector.
|
Vector2D |
round()
Rounds all components to the closest integer.
Components < 0.5 are rounded down, otherwise up |
Vector2D |
setX(double x)
Set X.
|
Vector2D |
setX(int x)
Set X.
|
Vector2D |
setZ(double z)
Set Z.
|
Vector2D |
setZ(int z)
Set Z.
|
Vector2D |
subtract(double x,
double z)
Subtract two points.
|
Vector2D |
subtract(int x,
int z)
Subtract two points.
|
Vector2D |
subtract(Vector2D... others)
Subtract points.
|
Vector2D |
subtract(Vector2D other)
Subtracts two points.
|
BlockVector2D |
toBlockVector2D()
Gets a BlockVector version.
|
String |
toString()
Returns string representation "(x, y, z)".
|
Vector |
toVector()
Creates a 3D vector by adding a zero Y component to this vector.
|
Vector |
toVector(double y)
Creates a 3D vector by adding the specified Y component to this vector.
|
Vector2D |
transform2D(double angle,
double aboutX,
double aboutZ,
double translateX,
double translateZ)
2D transformation.
|
public static final Vector2D ZERO
public static final Vector2D UNIT_X
public static final Vector2D UNIT_Z
public static final Vector2D ONE
protected final double x
protected final double z
public Vector2D(double x,
double z)
x - z - public Vector2D(int x,
int z)
x - z - public Vector2D(float x,
float z)
x - z - public Vector2D(Vector2D pt)
pt - public Vector2D()
public double getX()
public int getBlockX()
public Vector2D setX(double x)
x - public Vector2D setX(int x)
x - public double getZ()
public int getBlockZ()
public Vector2D setZ(double z)
z - public Vector2D setZ(int z)
z - public Vector2D add(double x, double z)
x - z - public Vector2D add(int x, int z)
x - z - public Vector2D subtract(Vector2D other)
other - public Vector2D subtract(double x, double z)
x - z - public Vector2D subtract(int x, int z)
x - z - public Vector2D subtract(Vector2D... others)
others - public Vector2D multiply(Vector2D other)
other - public Vector2D multiply(double x, double z)
x - z - public Vector2D multiply(int x, int z)
x - z - public Vector2D multiply(Vector2D... others)
others - public Vector2D multiply(double n)
n - public Vector2D multiply(float n)
n - public Vector2D multiply(int n)
n - public Vector2D divide(Vector2D other)
other - public Vector2D divide(double x, double z)
x - z - public Vector2D divide(int x, int z)
x - z - public Vector2D divide(int n)
n - public Vector2D divide(double n)
n - public Vector2D divide(float n)
n - public double length()
public double lengthSq()
public double distance(Vector2D pt)
pt - public double distanceSq(Vector2D pt)
pt - public Vector2D normalize()
public double dot(Vector2D other)
other - public boolean containedWithin(Vector2D min, Vector2D max)
min - max - public boolean containedWithinBlock(Vector2D min, Vector2D max)
min - max - public Vector2D floor()
public Vector2D ceil()
public Vector2D round()
public Vector2D positive()
public Vector2D 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 rotationpublic boolean isCollinearWith(Vector2D other)
public BlockVector2D toBlockVector2D()
public boolean equals(Object obj)
public int hashCode()
public String toString()
public Vector toVector()
public Vector toVector(double y)
public static Vector2D getMinimum(Vector2D v1, Vector2D v2)
v1 - v2 - Copyright © 2010-2014. All Rights Reserved.