Class Vector3f
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.vector.Vector
-
- net.lax1dude.eaglercraft.v1_8.vector.Vector3f
-
- All Implemented Interfaces:
java.io.Serializable
,ReadableVector
,ReadableVector2f
,ReadableVector3f
,WritableVector2f
,WritableVector3f
public class Vector3f extends Vector implements java.io.Serializable, ReadableVector3f, WritableVector3f
Holds a 3-tuple vector.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Vector3f()
Constructor for Vector3f.Vector3f(float x, float y, float z)
ConstructorVector3f(ReadableVector3f src)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Vector3f
add(Vector3f left, Vector3f right, Vector3f dest)
Add a vector to another vector and place the result in a destination vector.static float
angle(Vector3f a, Vector3f b)
Calculate the angle between two vectors, in radiansstatic Vector3f
cross(Vector3f left, Vector3f right, Vector3f dest)
The cross product of two vectors.static float
dot(Vector3f left, Vector3f right)
The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.zboolean
equals(java.lang.Object obj)
float
getX()
float
getY()
float
getZ()
float
lengthSquared()
Vector
load(FloatBuffer buf)
Load this vector from a FloatBufferVector
negate()
Negate a vectorVector3f
negate(Vector3f dest)
Negate a vector and place the result in a destination vector.Vector3f
normalise(Vector3f dest)
Normalise this vector and place the result in another vector.Vector
scale(float scale)
Scale this vectorvoid
set(float x, float y)
Set the X,Y valuesvoid
set(float x, float y, float z)
Set the X,Y,Z valuesVector3f
set(ReadableVector3f src)
Load from another Vector3fvoid
setX(float x)
Set Xvoid
setY(float y)
Set Yvoid
setZ(float z)
Set ZVector
store(FloatBuffer buf)
Store this vector in a FloatBufferstatic Vector3f
sub(Vector3f left, Vector3f right, Vector3f dest)
Subtract a vector from another vector and place the result in a destination vector.java.lang.String
toString()
Vector3f
translate(float x, float y, float z)
Translate a vector-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.lax1dude.eaglercraft.v1_8.vector.ReadableVector
length
-
-
-
-
Constructor Detail
-
Vector3f
public Vector3f()
Constructor for Vector3f.
-
Vector3f
public Vector3f(ReadableVector3f src)
Constructor
-
Vector3f
public Vector3f(float x, float y, float z)
Constructor
-
-
Method Detail
-
set
public void set(float x, float y)
Description copied from interface:WritableVector2f
Set the X,Y values- Specified by:
set
in interfaceWritableVector2f
-
set
public void set(float x, float y, float z)
Description copied from interface:WritableVector3f
Set the X,Y,Z values- Specified by:
set
in interfaceWritableVector3f
-
set
public Vector3f set(ReadableVector3f src)
Load from another Vector3f- Parameters:
src
- The source vector- Returns:
- this
-
lengthSquared
public float lengthSquared()
- Specified by:
lengthSquared
in interfaceReadableVector
- Specified by:
lengthSquared
in classVector
- Returns:
- the length squared of the vector
-
translate
public Vector3f translate(float x, float y, float z)
Translate a vector- Parameters:
x
- The translation in xy
- the translation in y- Returns:
- this
-
add
public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest)
Add a vector to another vector and place the result in a destination vector.- Parameters:
left
- The LHS vectorright
- The RHS vectordest
- The destination vector, or null if a new vector is to be created- Returns:
- the sum of left and right in dest
-
sub
public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest)
Subtract a vector from another vector and place the result in a destination vector.- Parameters:
left
- The LHS vectorright
- The RHS vectordest
- The destination vector, or null if a new vector is to be created- Returns:
- left minus right in dest
-
cross
public static Vector3f cross(Vector3f left, Vector3f right, Vector3f dest)
The cross product of two vectors.- Parameters:
left
- The LHS vectorright
- The RHS vectordest
- The destination result, or null if a new vector is to be created- Returns:
- left cross right
-
negate
public Vector3f negate(Vector3f dest)
Negate a vector and place the result in a destination vector.- Parameters:
dest
- The destination vector or null if a new vector is to be created- Returns:
- the negated vector
-
normalise
public Vector3f normalise(Vector3f dest)
Normalise this vector and place the result in another vector.- Parameters:
dest
- The destination vector, or null if a new vector is to be created- Returns:
- the normalised vector
-
dot
public static float dot(Vector3f left, Vector3f right)
The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.z- Parameters:
left
- The LHS vectorright
- The RHS vector- Returns:
- left dot right
-
angle
public static float angle(Vector3f a, Vector3f b)
Calculate the angle between two vectors, in radians- Parameters:
a
- A vectorb
- The other vector- Returns:
- the angle between the two vectors, in radians
-
load
public Vector load(FloatBuffer buf)
Description copied from class:Vector
Load this vector from a FloatBuffer
-
store
public Vector store(FloatBuffer buf)
Description copied from class:Vector
Store this vector in a FloatBuffer- Specified by:
store
in interfaceReadableVector
- Specified by:
store
in classVector
- Parameters:
buf
- The buffer to store it in, at the current position- Returns:
- this
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getX
public final float getX()
- Specified by:
getX
in interfaceReadableVector2f
- Returns:
- x
-
getY
public final float getY()
- Specified by:
getY
in interfaceReadableVector2f
- Returns:
- y
-
setX
public final void setX(float x)
Set X- Specified by:
setX
in interfaceWritableVector2f
- Parameters:
x
-
-
setY
public final void setY(float y)
Set Y- Specified by:
setY
in interfaceWritableVector2f
- Parameters:
y
-
-
setZ
public void setZ(float z)
Set Z- Specified by:
setZ
in interfaceWritableVector3f
- Parameters:
z
-
-
getZ
public float getZ()
- Specified by:
getZ
in interfaceReadableVector3f
- Returns:
- z
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-