![]() |
Bukkit
1.4.7-R1.0
|
Represents a mutable vector. More...
Inheritance diagram for org.bukkit.util.Vector:
Collaboration diagram for org.bukkit.util.Vector:Public Member Functions | |
| Vector () | |
| Construct the vector with all components as 0. | |
| Vector (int x, int y, int z) | |
| Construct the vector with provided integer components. | |
| 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 | add (Vector vec) |
| Adds a vector to this one. | |
| Vector | subtract (Vector vec) |
| Subtracts a vector from this one. | |
| Vector | multiply (Vector vec) |
| Multiplies the vector by another. | |
| Vector | divide (Vector vec) |
| Divides the vector by another. | |
| Vector | copy (Vector vec) |
| Copies another vector. | |
| 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. | |
| 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. | |
| float | angle (Vector other) |
| Gets the angle between this vector and another in radians. | |
| Vector | midpoint (Vector other) |
| Sets this vector to the midpoint between this vector and another. | |
| Vector | getMidpoint (Vector other) |
| Gets a new midpoint vector between this vector and another. | |
| Vector | multiply (int m) |
| Performs scalar multiplication, multiplying all components with a scalar. | |
| 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. | |
| double | dot (Vector other) |
| Calculates the dot product of this vector with another. | |
| Vector | crossProduct (Vector o) |
| Calculates the cross product of this vector with another. | |
| Vector | normalize () |
| Converts this vector to a unit vector (a vector with length of 1). | |
| Vector | zero () |
| Zero this vector's components. | |
| 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 | getX () |
| Gets the X component. | |
| int | getBlockX () |
| Gets the floored value of the X component, indicating the block that this vector is contained with. | |
| double | getY () |
| Gets the Y component. | |
| int | getBlockY () |
| Gets the floored value of the Y component, indicating the block that this vector is contained with. | |
| double | getZ () |
| Gets the Z component. | |
| int | getBlockZ () |
| Gets the floored value of the Z component, indicating the block that this vector is contained with. | |
| Vector | setX (int x) |
| Set the X component. | |
| Vector | setX (double x) |
| Set the X component. | |
| Vector | setX (float x) |
| Set the X component. | |
| Vector | setY (int y) |
| Set the Y component. | |
| Vector | setY (double y) |
| Set the Y component. | |
| Vector | setY (float y) |
| Set the Y component. | |
| Vector | setZ (int z) |
| Set the Z component. | |
| Vector | setZ (double z) |
| Set the Z component. | |
| Vector | setZ (float z) |
| Set the Z component. | |
| boolean | equals (Object obj) |
| Checks to see if two objects are equal. | |
| int | hashCode () |
| Returns a hash code for this vector. | |
| Vector | clone () |
| Get a new vector. | |
| String | toString () |
| Returns this vector's components as x,y,z. | |
| 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. | |
| BlockVector | toBlockVector () |
| Get the block vector of this vector. | |
| Map< String, Object > | serialize () |
Public Member Functions inherited from org.bukkit.configuration.serialization.ConfigurationSerializable | |
| Map< String, Object > | serialize () |
| Creates a Map representation of this class. | |
Static Public Member Functions | |
| static double | getEpsilon () |
| Get the threshold used for equals(). | |
| static Vector | getMinimum (Vector v1, Vector v2) |
| Gets the minimum components of two vectors. | |
| static Vector | getMaximum (Vector v1, Vector v2) |
| Gets the maximum components of two vectors. | |
| static Vector | getRandom () |
| Gets a random vector with components having a random value between 0 and 1. | |
| static Vector | deserialize (Map< String, Object > args) |
Protected Attributes | |
| double | x |
| double | y |
| double | z |
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.
Definition at line 18 of file Vector.java.
| org.bukkit.util.Vector.Vector | ( | ) |
Construct the vector with all components as 0.
Definition at line 35 of file Vector.java.
| org.bukkit.util.Vector.Vector | ( | int | x, |
| int | y, | ||
| int | z | ||
| ) |
Construct the vector with provided integer components.
| x | X component |
| y | Y component |
| z | Z component |
Definition at line 48 of file Vector.java.
| org.bukkit.util.Vector.Vector | ( | double | x, |
| double | y, | ||
| double | z | ||
| ) |
Construct the vector with provided double components.
| x | X component |
| y | Y component |
| z | Z component |
Definition at line 61 of file Vector.java.
| org.bukkit.util.Vector.Vector | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
Construct the vector with provided float components.
| x | X component |
| y | Y component |
| z | Z component |
Definition at line 74 of file Vector.java.
Adds a vector to this one.
| vec | The other vector |
Definition at line 86 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| float org.bukkit.util.Vector.angle | ( | Vector | other | ) |
Gets the angle between this vector and another in radians.
| other | The other vector |
Definition at line 197 of file Vector.java.
References org.bukkit.util.Vector.length().
| Vector org.bukkit.util.Vector.clone | ( | ) |
Get a new vector.
Definition at line 547 of file Vector.java.
References org.bukkit.util.Vector.clone().
Referenced by org.bukkit.util.BlockIterator.BlockIterator(), org.bukkit.util.Vector.clone(), org.bukkit.event.entity.EntityPortalExitEvent.getAfter(), org.bukkit.event.entity.EntityPortalExitEvent.getBefore(), org.bukkit.event.block.BlockDispenseEvent.getVelocity(), and org.bukkit.event.entity.EntityPortalExitEvent.setAfter().
Copies another vector.
| vec | The other vector |
Definition at line 138 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
Calculates the cross product of this vector with another.
The cross product is defined as:
x = y1 * z2 - y2 * z1
y = z1 * x2 - z2 * x1
z = x1 * y2 - x2 * y1
| o | The other vector |
Definition at line 290 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
|
static |
Definition at line 645 of file Vector.java.
| double org.bukkit.util.Vector.distance | ( | Vector | o | ) |
Get the distance between this vector and another.
The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the vector's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the distance is too long.
| o | The other vector |
Definition at line 177 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| double org.bukkit.util.Vector.distanceSquared | ( | Vector | o | ) |
Get the squared distance between this vector and another.
| o | The other vector |
Definition at line 187 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
Divides the vector by another.
| vec | The other vector |
Definition at line 125 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| double org.bukkit.util.Vector.dot | ( | Vector | other | ) |
Calculates the dot product of this vector with another.
The dot product is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
| other | The other vector |
Definition at line 275 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| boolean org.bukkit.util.Vector.equals | ( | Object | obj | ) |
Checks to see if two objects are equal.
Only two Vectors can ever return true. This method uses a fuzzy match to account for floating point errors. The epsilon can be retrieved with epsilon.
Definition at line 516 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| int org.bukkit.util.Vector.getBlockX | ( | ) |
Gets the floored value of the X component, indicating the block that this vector is contained with.
Definition at line 367 of file Vector.java.
References org.bukkit.util.NumberConversions.floor().
| int org.bukkit.util.Vector.getBlockY | ( | ) |
Gets the floored value of the Y component, indicating the block that this vector is contained with.
Definition at line 386 of file Vector.java.
References org.bukkit.util.NumberConversions.floor().
| int org.bukkit.util.Vector.getBlockZ | ( | ) |
Gets the floored value of the Z component, indicating the block that this vector is contained with.
Definition at line 405 of file Vector.java.
References org.bukkit.util.NumberConversions.floor().
|
static |
Get the threshold used for equals().
Definition at line 599 of file Vector.java.
Gets the maximum components of two vectors.
| v1 | The first vector. |
| v2 | The second vector. |
Definition at line 621 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
Gets a new midpoint vector between this vector and another.
| other | The other vector |
Definition at line 222 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
Gets the minimum components of two vectors.
| v1 | The first vector. |
| v2 | The second vector. |
Definition at line 610 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
|
static |
Gets a random vector with components having a random value between 0 and 1.
Definition at line 631 of file Vector.java.
| double org.bukkit.util.Vector.getX | ( | ) |
Gets the X component.
Definition at line 357 of file Vector.java.
Referenced by org.bukkit.Location.add(), org.bukkit.util.BlockIterator.BlockIterator(), org.bukkit.util.BlockVector.BlockVector(), org.bukkit.util.BlockVector.equals(), and org.bukkit.Location.subtract().
| double org.bukkit.util.Vector.getY | ( | ) |
Gets the Y component.
Definition at line 376 of file Vector.java.
Referenced by org.bukkit.Location.add(), org.bukkit.util.BlockIterator.BlockIterator(), org.bukkit.util.BlockVector.BlockVector(), org.bukkit.util.BlockVector.equals(), and org.bukkit.Location.subtract().
| double org.bukkit.util.Vector.getZ | ( | ) |
Gets the Z component.
Definition at line 395 of file Vector.java.
Referenced by org.bukkit.Location.add(), org.bukkit.util.BlockIterator.BlockIterator(), org.bukkit.util.BlockVector.BlockVector(), org.bukkit.util.BlockVector.equals(), and org.bukkit.Location.subtract().
| int org.bukkit.util.Vector.hashCode | ( | ) |
Returns whether this vector is in an axis-aligned bounding box.
The minimum and maximum vectors given must be truly the minimum and maximum X, Y and Z components.
| min | Minimum vector |
| max | Maximum vector |
Definition at line 337 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| boolean org.bukkit.util.Vector.isInSphere | ( | Vector | origin, |
| double | radius | ||
| ) |
Returns whether this vector is within a sphere.
| origin | Sphere origin. |
| radius | Sphere radius |
Definition at line 348 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| double org.bukkit.util.Vector.length | ( | ) |
Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2).
The value of this method is not cached and uses a costly square-root function, so do not repeatedly call this method to get the vector's magnitude. NaN will be returned if the inner result of the sqrt() function overflows, which will be caused if the length is too long.
Definition at line 154 of file Vector.java.
Referenced by org.bukkit.util.Vector.angle().
| double org.bukkit.util.Vector.lengthSquared | ( | ) |
Gets the magnitude of the vector squared.
Definition at line 163 of file Vector.java.
Sets this vector to the midpoint between this vector and another.
| other | The other vector |
Definition at line 209 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
Multiplies the vector by another.
| vec | The other vector |
Definition at line 112 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| Vector org.bukkit.util.Vector.multiply | ( | int | m | ) |
Performs scalar multiplication, multiplying all components with a scalar.
| m | The factor |
Definition at line 235 of file Vector.java.
| Vector org.bukkit.util.Vector.multiply | ( | double | m | ) |
Performs scalar multiplication, multiplying all components with a scalar.
| m | The factor |
Definition at line 248 of file Vector.java.
| Vector org.bukkit.util.Vector.multiply | ( | float | m | ) |
Performs scalar multiplication, multiplying all components with a scalar.
| m | The factor |
Definition at line 261 of file Vector.java.
| Vector org.bukkit.util.Vector.normalize | ( | ) |
Converts this vector to a unit vector (a vector with length of 1).
Definition at line 306 of file Vector.java.
| Map<String, Object> org.bukkit.util.Vector.serialize | ( | ) |
Definition at line 635 of file Vector.java.
| Vector org.bukkit.util.Vector.setX | ( | int | x | ) |
Set the X component.
| x | The new X component. |
Definition at line 415 of file Vector.java.
Referenced by org.bukkit.Location.getDirection().
| Vector org.bukkit.util.Vector.setX | ( | double | x | ) |
Set the X component.
| x | The new X component. |
Definition at line 426 of file Vector.java.
| Vector org.bukkit.util.Vector.setX | ( | float | x | ) |
Set the X component.
| x | The new X component. |
Definition at line 437 of file Vector.java.
| Vector org.bukkit.util.Vector.setY | ( | int | y | ) |
Set the Y component.
| y | The new Y component. |
Definition at line 448 of file Vector.java.
Referenced by org.bukkit.util.BlockIterator.BlockIterator(), and org.bukkit.Location.getDirection().
| Vector org.bukkit.util.Vector.setY | ( | double | y | ) |
Set the Y component.
| y | The new Y component. |
Definition at line 459 of file Vector.java.
| Vector org.bukkit.util.Vector.setY | ( | float | y | ) |
Set the Y component.
| y | The new Y component. |
Definition at line 470 of file Vector.java.
| Vector org.bukkit.util.Vector.setZ | ( | int | z | ) |
Set the Z component.
| z | The new Z component. |
Definition at line 481 of file Vector.java.
Referenced by org.bukkit.Location.getDirection().
| Vector org.bukkit.util.Vector.setZ | ( | double | z | ) |
Set the Z component.
| z | The new Z component. |
Definition at line 492 of file Vector.java.
| Vector org.bukkit.util.Vector.setZ | ( | float | z | ) |
Set the Z component.
| z | The new Z component. |
Definition at line 503 of file Vector.java.
Subtracts a vector from this one.
| vec | The other vector |
Definition at line 99 of file Vector.java.
References org.bukkit.util.Vector.x, org.bukkit.util.Vector.y, and org.bukkit.util.Vector.z.
| BlockVector org.bukkit.util.Vector.toBlockVector | ( | ) |
Get the block vector of this vector.
Definition at line 590 of file Vector.java.
Gets a Location version of this vector with yaw and pitch being 0.
| world | The world to link the location to. |
Definition at line 569 of file Vector.java.
Gets a Location version of this vector.
| world | The world to link the location to. |
| yaw | The desired yaw. |
| pitch | The desired pitch. |
Definition at line 581 of file Vector.java.
| String org.bukkit.util.Vector.toString | ( | ) |
Returns this vector's components as x,y,z.
Definition at line 559 of file Vector.java.
| Vector org.bukkit.util.Vector.zero | ( | ) |
|
protected |
Definition at line 28 of file Vector.java.
Referenced by org.bukkit.util.Vector.add(), org.bukkit.util.Vector.copy(), org.bukkit.util.Vector.crossProduct(), org.bukkit.util.Vector.distance(), org.bukkit.util.Vector.distanceSquared(), org.bukkit.util.Vector.divide(), org.bukkit.util.Vector.dot(), org.bukkit.util.Vector.equals(), org.bukkit.util.Vector.getMaximum(), org.bukkit.util.Vector.getMidpoint(), org.bukkit.util.Vector.getMinimum(), org.bukkit.util.Vector.isInAABB(), org.bukkit.util.Vector.isInSphere(), org.bukkit.util.Vector.midpoint(), org.bukkit.util.Vector.multiply(), and org.bukkit.util.Vector.subtract().
|
protected |
Definition at line 29 of file Vector.java.
Referenced by org.bukkit.util.Vector.add(), org.bukkit.util.Vector.copy(), org.bukkit.util.Vector.crossProduct(), org.bukkit.util.Vector.distance(), org.bukkit.util.Vector.distanceSquared(), org.bukkit.util.Vector.divide(), org.bukkit.util.Vector.dot(), org.bukkit.util.Vector.equals(), org.bukkit.util.Vector.getMaximum(), org.bukkit.util.Vector.getMidpoint(), org.bukkit.util.Vector.getMinimum(), org.bukkit.util.Vector.isInAABB(), org.bukkit.util.Vector.isInSphere(), org.bukkit.util.Vector.midpoint(), org.bukkit.util.Vector.multiply(), and org.bukkit.util.Vector.subtract().
|
protected |
Definition at line 30 of file Vector.java.
Referenced by org.bukkit.util.Vector.add(), org.bukkit.util.Vector.copy(), org.bukkit.util.Vector.crossProduct(), org.bukkit.util.Vector.distance(), org.bukkit.util.Vector.distanceSquared(), org.bukkit.util.Vector.divide(), org.bukkit.util.Vector.dot(), org.bukkit.util.Vector.equals(), org.bukkit.util.Vector.getMaximum(), org.bukkit.util.Vector.getMidpoint(), org.bukkit.util.Vector.getMinimum(), org.bukkit.util.Vector.isInAABB(), org.bukkit.util.Vector.isInSphere(), org.bukkit.util.Vector.midpoint(), org.bukkit.util.Vector.multiply(), and org.bukkit.util.Vector.subtract().