|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.util.Vector
public class Vector
Represents a mutable vector. Because the components of Vectors are mutable,
storing Vectors long term may be dangerous if passing code modifies the
Vector later. If you want to keep around a Vector, it may be wise to call
clone()
in order to get a copy.
Field Summary | |
---|---|
protected double |
x
|
protected double |
y
|
protected double |
z
|
Constructor Summary | |
---|---|
Vector()
Construct the vector with all components as 0. |
|
Vector(double x,
double y,
double z)
Construct the vector with provided double components. |
|
Vector(float x,
float y,
float z)
Construct the vector with provided float components. |
|
Vector(int x,
int y,
int z)
Construct the vector with provided integer components. |
Method Summary | |
---|---|
Vector |
add(Vector vec)
Adds a vector to this one |
float |
angle(Vector other)
Gets the angle between this vector and another in radians. |
Vector |
clone()
Get a new vector. |
Vector |
copy(Vector vec)
Copies another vector |
Vector |
crossProduct(Vector o)
Calculates the cross product of this vector with another. |
static Vector |
deserialize(Map<String,Object> args)
|
double |
distance(Vector o)
Get the distance between this vector and another. |
double |
distanceSquared(Vector o)
Get the squared distance between this vector and another. |
Vector |
divide(Vector vec)
Divides the vector by another. |
double |
dot(Vector other)
Calculates the dot product of this vector with another. |
boolean |
equals(Object obj)
Checks to see if two objects are equal. |
int |
getBlockX()
Gets the floored value of the X component, indicating the block that this vector is contained with. |
int |
getBlockY()
Gets the floored value of the Y component, indicating the block that this vector is contained with. |
int |
getBlockZ()
Gets the floored value of the Z component, indicating the block that this vector is contained with. |
static double |
getEpsilon()
Get the threshold used for equals(). |
static Vector |
getMaximum(Vector v1,
Vector v2)
Gets the maximum components of two vectors. |
Vector |
getMidpoint(Vector other)
Gets a new midpoint vector between this vector and another. |
static Vector |
getMinimum(Vector v1,
Vector v2)
Gets the minimum components of two vectors. |
static Vector |
getRandom()
Gets a random vector with components having a random value between 0 and 1. |
double |
getX()
Gets the X component. |
double |
getY()
Gets the Y component. |
double |
getZ()
Gets the Z component. |
int |
hashCode()
Returns a hash code for this vector |
boolean |
isInAABB(Vector min,
Vector max)
Returns whether this vector is in an axis-aligned bounding box. |
boolean |
isInSphere(Vector origin,
double radius)
Returns whether this vector is within a sphere. |
double |
length()
Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). |
double |
lengthSquared()
Gets the magnitude of the vector squared. |
Vector |
midpoint(Vector other)
Sets this vector to the midpoint between this vector and another. |
Vector |
multiply(double m)
Performs scalar multiplication, multiplying all components with a scalar. |
Vector |
multiply(float m)
Performs scalar multiplication, multiplying all components with a scalar. |
Vector |
multiply(int m)
Performs scalar multiplication, multiplying all components with a scalar. |
Vector |
multiply(Vector vec)
Multiplies the vector by another. |
Vector |
normalize()
Converts this vector to a unit vector (a vector with length of 1). |
Map<String,Object> |
serialize()
Creates a Map representation of this class. |
Vector |
setX(double x)
Set the X component. |
Vector |
setX(float x)
Set the X component. |
Vector |
setX(int x)
Set the X component. |
Vector |
setY(double y)
Set the Y component. |
Vector |
setY(float y)
Set the Y component. |
Vector |
setY(int y)
Set the Y component. |
Vector |
setZ(double z)
Set the Z component. |
Vector |
setZ(float z)
Set the Z component. |
Vector |
setZ(int z)
Set the Z component. |
Vector |
subtract(Vector vec)
Subtracts a vector from this one. |
BlockVector |
toBlockVector()
Get the block vector of this vector. |
Location |
toLocation(World world)
Gets a Location version of this vector with yaw and pitch being 0. |
Location |
toLocation(World world,
float yaw,
float pitch)
Gets a Location version of this vector. |
String |
toString()
Returns this vector's components as x,y,z. |
Vector |
zero()
Zero this vector's components. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double x
protected double y
protected double z
Constructor Detail |
---|
public Vector()
public Vector(int x, int y, int z)
x
- X componenty
- Y componentz
- Z componentpublic Vector(double x, double y, double z)
x
- X componenty
- Y componentz
- Z componentpublic Vector(float x, float y, float z)
x
- X componenty
- Y componentz
- Z componentMethod Detail |
---|
public Vector add(Vector vec)
vec
- The other vector
public Vector subtract(Vector vec)
vec
- The other vector
public Vector multiply(Vector vec)
vec
- The other vector
public Vector divide(Vector vec)
vec
- The other vector
public Vector copy(Vector vec)
vec
- The other vector
public double length()
public double lengthSquared()
public double distance(Vector o)
o
- The other vector
public double distanceSquared(Vector o)
o
- The other vector
public float angle(Vector other)
other
- The other vector
public Vector midpoint(Vector other)
other
- The other vector
public Vector getMidpoint(Vector other)
other
- The other vector
public Vector multiply(int m)
m
- The factor
public Vector multiply(double m)
m
- The factor
public Vector multiply(float m)
m
- The factor
public double dot(Vector other)
other
- The other vector
public Vector crossProduct(Vector o)
o
- The other vector
public Vector normalize()
public Vector zero()
public boolean isInAABB(Vector min, Vector max)
min
- Minimum vectormax
- Maximum vector
public boolean isInSphere(Vector origin, double radius)
origin
- Sphere origin.radius
- Sphere radius
public double getX()
public int getBlockX()
public double getY()
public int getBlockY()
public double getZ()
public int getBlockZ()
public Vector setX(int x)
x
- The new X component.
public Vector setX(double x)
x
- The new X component.
public Vector setX(float x)
x
- The new X component.
public Vector setY(int y)
y
- The new Y component.
public Vector setY(double y)
y
- The new Y component.
public Vector setY(float y)
y
- The new Y component.
public Vector setZ(int z)
z
- The new Z component.
public Vector setZ(double z)
z
- The new Z component.
public Vector setZ(float z)
z
- The new Z component.
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public Vector clone()
clone
in class Object
public String toString()
toString
in class Object
public Location toLocation(World world)
world
- The world to link the location to.
public Location toLocation(World world, float yaw, float pitch)
world
- The world to link the location to.yaw
- The desired yaw.pitch
- The desired pitch.
public BlockVector toBlockVector()
public static double getEpsilon()
public static Vector getMinimum(Vector v1, Vector v2)
v1
- The first vector.v2
- The second vector.
public static Vector getMaximum(Vector v1, Vector v2)
v1
- The first vector.v2
- The second vector.
public static Vector getRandom()
public Map<String,Object> serialize()
ConfigurationSerializable
ConfigurationSerializable
interface javadocs.
serialize
in interface ConfigurationSerializable
public static Vector deserialize(Map<String,Object> args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |