Class Vector2f
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.vector.Vector
-
- net.lax1dude.eaglercraft.v1_8.vector.Vector2f
-
- All Implemented Interfaces:
java.io.Serializable,ReadableVector,ReadableVector2f,WritableVector2f
public class Vector2f extends Vector implements java.io.Serializable, ReadableVector2f, WritableVector2f
Holds a 2-tuple vector.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Vector2f()Constructor for Vector2f.Vector2f(float x, float y)Constructor.Vector2f(ReadableVector2f src)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Vector2fadd(Vector2f left, Vector2f right, Vector2f dest)Add a vector to another vector and place the result in a destination vector.static floatangle(Vector2f a, Vector2f b)Calculate the angle between two vectors, in radiansstatic floatdot(Vector2f left, Vector2f right)The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.zbooleanequals(java.lang.Object obj)floatgetX()floatgetY()floatlengthSquared()Vectorload(FloatBuffer buf)Load this vector from a FloatBufferVectornegate()Negate a vectorVector2fnegate(Vector2f dest)Negate a vector and place the result in a destination vector.Vector2fnormalise(Vector2f dest)Normalise this vector and place the result in another vector.Vectorscale(float scale)Scale this vectorvoidset(float x, float y)Set the X,Y valuesVector2fset(ReadableVector2f src)Load from another Vector2fvoidsetX(float x)Set XvoidsetY(float y)Set YVectorstore(FloatBuffer buf)Store this vector in a FloatBufferstatic Vector2fsub(Vector2f left, Vector2f right, Vector2f dest)Subtract a vector from another vector and place the result in a destination vector.java.lang.StringtoString()Vector2ftranslate(float x, float y)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
-
Vector2f
public Vector2f()
Constructor for Vector2f.
-
Vector2f
public Vector2f(ReadableVector2f src)
Constructor.
-
Vector2f
public Vector2f(float x, float y)Constructor.
-
-
Method Detail
-
set
public void set(float x, float y)Description copied from interface:WritableVector2fSet the X,Y values- Specified by:
setin interfaceWritableVector2f
-
set
public Vector2f set(ReadableVector2f src)
Load from another Vector2f- Parameters:
src- The source vector- Returns:
- this
-
lengthSquared
public float lengthSquared()
- Specified by:
lengthSquaredin interfaceReadableVector- Specified by:
lengthSquaredin classVector- Returns:
- the length squared of the vector
-
translate
public Vector2f translate(float x, float y)
Translate a vector- Parameters:
x- The translation in xy- the translation in y- Returns:
- this
-
negate
public Vector2f negate(Vector2f 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 Vector2f normalise(Vector2f 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(Vector2f left, Vector2f 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(Vector2f a, Vector2f 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
-
add
public static Vector2f add(Vector2f left, Vector2f right, Vector2f 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 Vector2f sub(Vector2f left, Vector2f right, Vector2f 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
-
store
public Vector store(FloatBuffer buf)
Store this vector in a FloatBuffer- Specified by:
storein interfaceReadableVector- Specified by:
storein classVector- Parameters:
buf- The buffer to store it in, at the current position- Returns:
- this
-
load
public Vector load(FloatBuffer buf)
Load this vector from a FloatBuffer
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getX
public final float getX()
- Specified by:
getXin interfaceReadableVector2f- Returns:
- x
-
getY
public final float getY()
- Specified by:
getYin interfaceReadableVector2f- Returns:
- y
-
setX
public final void setX(float x)
Set X- Specified by:
setXin interfaceWritableVector2f- Parameters:
x-
-
setY
public final void setY(float y)
Set Y- Specified by:
setYin interfaceWritableVector2f- Parameters:
y-
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-