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