Package net.risingworld.api.utils
Klasse Vector3f
java.lang.Object
net.risingworld.api.utils.Vector3f
- Alle implementierten Schnittstellen:
Serializable
A Vector which holds three float values: X, Y and Z
It can be used to represent a three dimensional value, like a position or a direction.
It can be used to represent a three dimensional value, like a position or a direction.
- Siehe auch:
-
Feldübersicht
Modifizierer und TypFeldBeschreibungstatic final Vector3f
A unit vector along the -Z axis (backward direction)static final Vector3f
A unit vector along the -Y axis (down direction)static final Vector3f
A unit vector along the Z axis (forward direction)static final Vector3f
A unit vector along the -X axis (left direction)static final Vector3f
A vector with values 1, 1, 1static final Vector3f
A unit vector along the X axis (right direction)static final Vector3f
A unit vector along the Y axis (up direction)float
The X value of this vectorfloat
The Y value of this vectorfloat
The Z value of this vectorstatic final Vector3f
A vector with values 0, 0, 0 -
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungadd
(float addX, float addY, float addZ) Creates a new vector with the same values of this vector and adds the provided values.Creates a new vector with the same values of this vector and adds the values of the provided vector.addLocal
(float addX, float addY, float addZ) Adds the provided values to the values of this vector.Adds the values of the provided vector to the values of this vector.float
angleBetween
(Vector3f other) Gets the angle between this vector and another vector.copy()
Creates a copy of this Vector.Creates a new vector containing the cross product of this vector and another vector.crossLocal
(float v2x, float v2y, float v2z) Calculates the cross product of this vector and the provided coordinates.crossLocal
(Vector3f other) Calculates the cross product of this vector and another vector.float
distance
(float x, float y, float z) Gets the distance between this vector and the provided coordinates.float
Gets the distance between this vector and another vector.float
distanceSquared
(float x, float y, float z) Gets the squared distance between this vector and the provided coordinates.float
distanceSquared
(Vector3f other) Gets the squared distance between this vector and another Vector3f.Creates a new vector with the same values of this vector and divides the values of the provided vector.divideLocal
(float scalar) divideLocal
(Vector3f other) float
dot
(float x, float y, float z) Gets the dot product of this vector with the provided coordinates.float
Gets the dot product of this vector with the provided vector.boolean
equals
(float x, float y, float z) boolean
Gets whether or not this vector is equal to another object.fromString
(String input) float
getX()
Returns the x value of this vector.float
getY()
Returns the y value of this vector.float
getZ()
Returns the z value of this vector.int
hashCode()
Gets a unique* hash code for this vector, based on its values.interpolate
(Vector3f startVector, Vector3f finalVector, float mu) Creates a new vector containing the interpolated values between the start vector and the final vector.interpolateLocal
(Vector3f finalVector, float mu) Interpolates this vector to the provided final vector, e.g if this vector is (0, 5, 10), and the final vector is (-10, 0, 10), the result (by using a mu-value of 0.5f) would be (-5, 2.5f, 10)interpolateLocal
(Vector3f startVector, Vector3f finalVector, float mu) Interpolates between the provided start and end vector and stores the result in this vector.boolean
isOrthogonal
(float x, float y, float z) Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).boolean
isOrthogonal
(Vector3f other) Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).boolean
Checks if this vector is a unit vector.float
length()
Gets the length of this vector.float
Gets the squared length of this vector.mult
(float scalar) Creates a new vector with the same values of this vector and multiplies them with the provided scalar.mult
(float multX, float multY, float multZ) Creates a new vector with the same values of this vector and multiplies the provided values.Creates a new vector with the same values of this vector and multiplies the values of the provided vector.multLocal
(float scalar) Multiplies the values of this vector with the provided scalar.multLocal
(float multX, float multY, float multZ) Multiplies the values of this vector with the provided values.Multiplies the values of this vector with the values of the provided vector.negate()
Creates a new vector which contains negated values of this vector.Negates all values of this vector.Creates a new vector containing normalized values of this vector (i.e as a unit vector).Normalizes this vector (i.e turn it into a unit vector).set
(float x, float y, float z) Sets the x, y and z values of this vector to the provided values.Sets the x, y and z values of this vector to the values of the provided vector.setX
(float x) Sets the x value of this vector.setY
(float y) Sets the y value of this vector.setZ
(float z) Sets the z value of this vector.subtract
(float subtractX, float subtractY, float subtractZ) Creates a new vector with the same values of this vector and subtracts the provided values.Creates a new vector with the same values of this vector and subtracts the values of the provided vector.subtractLocal
(float subtractX, float subtractY, float subtractZ) Subtracts the provided values from the values of this vector.subtractLocal
(Vector3f other) Subtracts the values of the provided vector from the values of this vector.toString()
Gets a String representation of this vector, for example(4.0, 5.25, 10.998)
-
Felddetails
-
ZERO
A vector with values 0, 0, 0 -
ONE
A vector with values 1, 1, 1 -
RIGHT
A unit vector along the X axis (right direction) -
LEFT
A unit vector along the -X axis (left direction) -
UP
A unit vector along the Y axis (up direction) -
DOWN
A unit vector along the -Y axis (down direction) -
FORWARD
A unit vector along the Z axis (forward direction) -
BACK
A unit vector along the -Z axis (backward direction) -
x
public float xThe X value of this vector -
y
public float yThe Y value of this vector -
z
public float zThe Z value of this vector
-
-
Konstruktordetails
-
Vector3f
public Vector3f()Creates a new Vector3f with default values 0, 0, 0. -
Vector3f
public Vector3f(float x, float y, float z) Creates a new Vector3f with the provided values.- Parameter:
x
- the x value of the vector.y
- the y value of the vector.z
- the z value of the vector.
-
Vector3f
Creates a new Vector3f and copies the X, Y and Z values from the provided vector.- Parameter:
copy
- the Vector3f to copy.
-
-
Methodendetails
-
copy
Creates a copy of this Vector.- Gibt zurück:
- a new instance with the same values of this Vector.
-
set
Sets the x, y and z values of this vector to the values of the provided vector.- Parameter:
vector
- the Vector3f to copy.- Gibt zurück:
- this vector.
-
set
Sets the x, y and z values of this vector to the provided values.- Parameter:
x
- the x value.y
- the y value.z
- the z value.- Gibt zurück:
- this vector.
-
setX
Sets the x value of this vector.- Parameter:
x
- the new x value.- Gibt zurück:
- this vector.
-
setY
Sets the y value of this vector.- Parameter:
y
- the new y value.- Gibt zurück:
- this vector.
-
setZ
Sets the z value of this vector.- Parameter:
z
- the new z value.- Gibt zurück:
- this vector.
-
getX
public float getX()Returns the x value of this vector.- Gibt zurück:
- the current x value.
-
getY
public float getY()Returns the y value of this vector.- Gibt zurück:
- the current y value.
-
getZ
public float getZ()Returns the z value of this vector.- Gibt zurück:
- the current z value.
-
dot
Gets the dot product of this vector with the provided vector.- Parameter:
other
- the vector to calculate the dot product with.- Gibt zurück:
- the resulting dot product.
-
dot
public float dot(float x, float y, float z) Gets the dot product of this vector with the provided coordinates.- Parameter:
x
- the x coordinate.y
- the y coordinate.z
- the z coordinate.- Gibt zurück:
- the resulting dot product.
-
length
public float length()Gets the length of this vector.- Gibt zurück:
- the length of this vector.
- Siehe auch:
-
lengthSquared
public float lengthSquared()Gets the squared length of this vector. Use this function to avoid calculating the squareroot.- Gibt zurück:
- the squared length of this vector.
- Siehe auch:
-
distance
Gets the distance between this vector and another vector.- Parameter:
other
- the other vector.- Gibt zurück:
- the distance between this vector and another vector.
- Siehe auch:
-
distance
public float distance(float x, float y, float z) Gets the distance between this vector and the provided coordinates.- Parameter:
x
- the other x coordinate.y
- the other y coordinate.z
- the other z coordinate.- Gibt zurück:
- the distance between this vector and the provided coordinates.
- Siehe auch:
-
distanceSquared
Gets the squared distance between this vector and another Vector3f. Use this function to avoid calculating the squareroot.- Parameter:
other
- the other Vector3f.- Gibt zurück:
- the squared distance between this vector and the provided Vector3f.
-
distanceSquared
public float distanceSquared(float x, float y, float z) Gets the squared distance between this vector and the provided coordinates. Use this function to avoid calculating the squareroot.- Parameter:
x
- the other x coordinate.y
- the other y coordinate.z
- the other z coordinate.- Gibt zurück:
- the squared distance between this vector and the provided coordinates.
-
add
Creates a new vector with the same values of this vector and adds the values of the provided vector. Same asnew Vector3f(this).addLocal(other);
- Parameter:
other
- the vector to add.- Gibt zurück:
- the newly created vector.
-
add
Creates a new vector with the same values of this vector and adds the provided values. Same asnew Vector3f(this).addLocal(x, y, z);
- Parameter:
addX
- the x value to add.addY
- the y value to add.addZ
- the z value to add.- Gibt zurück:
- the newly created vector.
-
addLocal
Adds the values of the provided vector to the values of this vector.- Parameter:
other
- the vector to add.- Gibt zurück:
- this vector.
-
addLocal
Adds the provided values to the values of this vector.- Parameter:
addX
- the x value to add.addY
- the y value to add.addZ
- the z value to add.- Gibt zurück:
- this vector.
-
subtract
Creates a new vector with the same values of this vector and subtracts the values of the provided vector. Same asnew Vector3f(this).subtractLocal(other);
- Parameter:
other
- the vector to subtract.- Gibt zurück:
- the newly created vector.
-
subtract
Creates a new vector with the same values of this vector and subtracts the provided values. Same asnew Vector3f(this).subtractLocal(x, y, z);
- Parameter:
subtractX
- the x value to subtract.subtractY
- the y value to subtract.subtractZ
- the z value to subtract.- Gibt zurück:
- the newly created vector.
-
subtractLocal
Subtracts the values of the provided vector from the values of this vector.- Parameter:
other
- the vector to subtract.- Gibt zurück:
- this vector.
-
subtractLocal
Subtracts the provided values from the values of this vector.- Parameter:
subtractX
- the x value to subtract.subtractY
- the y value to subtract.subtractZ
- the z value to subtract.- Gibt zurück:
- this vector.
-
mult
Creates a new vector with the same values of this vector and multiplies them with the provided scalar.- Parameter:
scalar
- the value to multiply the vector by.- Gibt zurück:
- the newly created vector.
-
mult
Creates a new vector with the same values of this vector and multiplies the values of the provided vector. Same asnew Vector3f(this).multLocal(other);
- Parameter:
other
- the vector to multiply.- Gibt zurück:
- the newly created vector.
-
mult
Creates a new vector with the same values of this vector and multiplies the provided values. Same asnew Vector3f(this).multLocal(x, y, z);
- Parameter:
multX
- the x value to multiply.multY
- the y value to multiply.multZ
- the z value to multiply.- Gibt zurück:
- the newly created vector.
-
multLocal
Multiplies the values of this vector with the provided scalar.- Parameter:
scalar
- the value to multiply this vector by.- Gibt zurück:
- this vector.
-
multLocal
Multiplies the values of this vector with the values of the provided vector.- Parameter:
other
- the vector to multiply.- Gibt zurück:
- this vector.
-
multLocal
Multiplies the values of this vector with the provided values.- Parameter:
multX
- the x value to multiply the x coordinate of this vector by.multY
- the y value to multiply the y coordinate of this vector by.multZ
- the z value to multiply the z coordinate of this vector by.- Gibt zurück:
- this vector.
-
divide
Creates a new vector with the same values of this vector and divides the values of the provided vector. Same asnew Vector3f(this).divideLocal(other);
- Parameter:
other
- the vector to divide.- Gibt zurück:
- the newly created vector.
-
divideLocal
-
divideLocal
-
negate
Creates a new vector which contains negated values of this vector.- Gibt zurück:
- the newly created vector.
-
negateLocal
Negates all values of this vector.- Gibt zurück:
- this vector.
-
cross
Creates a new vector containing the cross product of this vector and another vector.- Parameter:
other
- the other vector.- Gibt zurück:
- the newly created vector.
-
crossLocal
Calculates the cross product of this vector and another vector.- Parameter:
other
- the other vector.- Gibt zurück:
- this vector.
-
crossLocal
Calculates the cross product of this vector and the provided coordinates.- Parameter:
v2x
- the other x coordinate.v2y
- the other y coordinate.v2z
- the other z coordinate.- Gibt zurück:
- this vector.
-
normalize
Creates a new vector containing normalized values of this vector (i.e as a unit vector).- Gibt zurück:
- a newly created, normalized vector.
-
normalizeLocal
Normalizes this vector (i.e turn it into a unit vector).- Gibt zurück:
- this vector (normalized).
-
angleBetween
Gets the angle between this vector and another vector.- Parameter:
other
- the other vector (unit vector).- Gibt zurück:
- the angle in degrees.
-
isUnitVector
public boolean isUnitVector()Checks if this vector is a unit vector.- Gibt zurück:
- true if this is a unit vector, false if not.
-
isOrthogonal
Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).- Parameter:
other
- the other vector.- Gibt zurück:
- true if this vector is orthogonal to the other vector, false if not.
-
isOrthogonal
public boolean isOrthogonal(float x, float y, float z) Checks if this vector is orthogonal to another vector (i.e the angle between both vectors is ~ 90° degree).- Parameter:
x
- the x coordinate of the other vector.y
- the y coordinate of the other vector.z
- the z coordinate of the other vector.- Gibt zurück:
- true if this vector is orthogonal to the other vector, false if not.
-
interpolateLocal
Interpolates this vector to the provided final vector, e.g if this vector is (0, 5, 10), and the final vector is (-10, 0, 10), the result (by using a mu-value of 0.5f) would be (-5, 2.5f, 10)- Parameter:
finalVector
- the final vector to interpolate towards.mu
- the mu value between 0.0 and 1.0 (i.e the percentage change from this vector to towards the final vector).- Gibt zurück:
- this vector containing the interpolated values.
-
interpolateLocal
Interpolates between the provided start and end vector and stores the result in this vector.- Parameter:
startVector
- the start vector to interpolate from.finalVector
- the final vector to interpolate towards.mu
- the mu value between 0.0 and 1.0 (i.e the percentage change from the start vector to towards the final vector).- Gibt zurück:
- this vector containing the interpolated values.
-
interpolate
Creates a new vector containing the interpolated values between the start vector and the final vector.- Parameter:
startVector
- the start vector to interpolate from.finalVector
- the final vector to interpolate towards.mu
- the mu value between 0.0 and 1.0 (i.e the percentage change from the start vector to towards the final vector).- Gibt zurück:
- a new vector containing the interpolated values.
-
equals
Gets whether or not this vector is equal to another object. This function returns true, if the other object is aVector3f
and if it has exactly the same x, y and z values. -
equals
public boolean equals(float x, float y, float z) -
hashCode
public int hashCode()Gets a unique* hash code for this vector, based on its values. If two vectors have the same x, y and z values, they will return the same hash code.
* Please keep in mind that the uniqueness is not fully reliable. There is always a small chance that collisions occur (i.e two completely different vectors return the same hash code). But usually the reliability is sufficient. -
toString
Gets a String representation of this vector, for example(4.0, 5.25, 10.998)
-
fromString
-