Top Description Fields Constructors Methods
org.lwjgl.util.vector

public Class Vector2f

extends Vector
implements Serializable, ReadableVector2f, WritableVector2f
Class Inheritance
All Implemented Interfaces
org.lwjgl.util.vector.WritableVector2f, org.lwjgl.util.vector.ReadableVector2f, org.lwjgl.util.vector.ReadableVector, java.io.Serializable
Imports
java.io.Serializable, java.nio.FloatBuffer, org.lwjgl.util.vector.Vector2f

Holds a 2-tuple vector.
Author
cix_foo
Version
$Revision$ $Id$

Field Summary

Modifier and TypeField and Description
private static final long
public float
x

public float
y

Constructor Summary

AccessConstructor and Description
public
Vector2f()

Constructor for Vector3f.

public
Vector2f(ReadableVector2f src)

Constructor

public
Vector2f(float x, float y)

Constructor

Method Summary

Modifier and TypeMethod and Description
public static Vector2f

Returns:

the sum of left and right in dest
add
(Vector2f
The LHS vector
left
,
Vector2f
The RHS vector
right
,
Vector2f
The destination vector, or null if a new vector is to be created
dest
)

Add a vector to another vector and place the result in a destination vector.

public static float

Returns:

the angle between the two vectors, in radians
angle
(Vector2f
A vector
a
,
Vector2f
The other vector
b
)

Calculate the angle between two vectors, in radians

public static float

Returns:

left dot right
dot
(Vector2f
The LHS vector
left
,
Vector2f
The RHS vector
right
)

The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.z

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public final float
public final float
public float

Returns:

the length squared of the vector
lengthSquared
()

Implements abstract org.lwjgl.util.vector.Vector.lengthSquared.

Implements org.lwjgl.util.vector.ReadableVector.lengthSquared.

public Vector

Returns:

this
load
(FloatBuffer
The buffer to load it from, at the current position
buf
)

Implements abstract org.lwjgl.util.vector.Vector.load.

Load this vector from a FloatBuffer
public Vector

Returns:

this
negate
()

Implements abstract org.lwjgl.util.vector.Vector.negate.

Negate a vector
public Vector2f

Returns:

the negated vector
negate
(Vector2f
The destination vector or null if a new vector is to be created
dest
)

Negate a vector and place the result in a destination vector.

public Vector2f

Returns:

the normalised vector
normalise
(Vector2f
The destination vector, or null if a new vector is to be created
dest
)

Normalise this vector and place the result in another vector.

public Vector
scale(float
The scale factor
scale
)

Implements abstract org.lwjgl.util.vector.Vector.scale.

Scale this vector
public void
set(float x, float y)

Implements org.lwjgl.util.vector.WritableVector2f.set.

Set the X,Y values
public Vector2f

Returns:

this
set
(ReadableVector2f
The source vector
src
)

Load from another Vector2f

public final void
public final void
public Vector

Returns:

this
store
(FloatBuffer
The buffer to store it in, at the current position
buf
)

Implements abstract org.lwjgl.util.vector.Vector.store.

Implements org.lwjgl.util.vector.ReadableVector.store.

Store this vector in a FloatBuffer
public static Vector2f

Returns:

left minus right in dest
sub
(Vector2f
The LHS vector
left
,
Vector2f
The RHS vector
right
,
Vector2f
The destination vector, or null if a new vector is to be created
dest
)

Subtract a vector from another vector and place the result in a destination vector.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Vector2f

Returns:

this
translate
(float
The translation in x
x
,
float
the translation in y
y
)

Translate a vector

Inherited from org.lwjgl.util.vector.Vector:
lengthnormalise

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
xback to summary
public float x
yback to summary
public float y

Constructor Detail

Vector2fback to summary
public Vector2f()

Constructor for Vector3f.

Vector2fback to summary
public Vector2f(ReadableVector2f src)

Constructor

Vector2fback to summary
public Vector2f(float x, float y)

Constructor

Method Detail

addback to summary
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:Vector2f

The LHS vector

right:Vector2f

The RHS vector

dest:Vector2f

The destination vector, or null if a new vector is to be created

Returns:Vector2f

the sum of left and right in dest

angleback to summary
public static float angle(Vector2f a, Vector2f b)

Calculate the angle between two vectors, in radians

Parameters
a:Vector2f

A vector

b:Vector2f

The other vector

Returns:float

the angle between the two vectors, in radians

dotback to summary
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:Vector2f

The LHS vector

right:Vector2f

The RHS vector

Returns:float

left dot right

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getXback to summary
public final float getX()

Implements org.lwjgl.util.vector.ReadableVector2f.getX.

Returns:float

x

getYback to summary
public final float getY()

Implements org.lwjgl.util.vector.ReadableVector2f.getY.

Returns:float

y

lengthSquaredback to summary
public float lengthSquared()

Implements abstract org.lwjgl.util.vector.Vector.lengthSquared.

Implements org.lwjgl.util.vector.ReadableVector.lengthSquared.

Returns:float

the length squared of the vector

loadback to summary
public Vector load(FloatBuffer buf)

Implements abstract org.lwjgl.util.vector.Vector.load.

Load this vector from a FloatBuffer

Parameters
buf:FloatBuffer

The buffer to load it from, at the current position

Returns:Vector

this

negateback to summary
public Vector negate()

Implements abstract org.lwjgl.util.vector.Vector.negate.

Negate a vector

Returns:Vector

this

negateback to summary
public Vector2f negate(Vector2f dest)

Negate a vector and place the result in a destination vector.

Parameters
dest:Vector2f

The destination vector or null if a new vector is to be created

Returns:Vector2f

the negated vector

normaliseback to summary
public Vector2f normalise(Vector2f dest)

Normalise this vector and place the result in another vector.

Parameters
dest:Vector2f

The destination vector, or null if a new vector is to be created

Returns:Vector2f

the normalised vector

scaleback to summary
public Vector scale(float scale)

Implements abstract org.lwjgl.util.vector.Vector.scale.

Doc from org.lwjgl.util.vector.Vector.scale.

Scale this vector

Parameters
scale:float

The scale factor

Returns:Vector

this

setback to summary
public void set(float x, float y)

Implements org.lwjgl.util.vector.WritableVector2f.set.

Doc from org.lwjgl.util.vector.WritableVector2f.set.

Set the X,Y values

setback to summary
public Vector2f set(ReadableVector2f src)

Load from another Vector2f

Parameters
src:ReadableVector2f

The source vector

Returns:Vector2f

this

setXback to summary
public final void setX(float x)

Implements org.lwjgl.util.vector.WritableVector2f.setX.

Set X

setYback to summary
public final void setY(float y)

Implements org.lwjgl.util.vector.WritableVector2f.setY.

Set Y

storeback to summary
public Vector store(FloatBuffer buf)

Implements abstract org.lwjgl.util.vector.Vector.store.

Implements org.lwjgl.util.vector.ReadableVector.store.

Store this vector in a FloatBuffer

Parameters
buf:FloatBuffer

The buffer to store it in, at the current position

Returns:Vector

this

subback to summary
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:Vector2f

The LHS vector

right:Vector2f

The RHS vector

dest:Vector2f

The destination vector, or null if a new vector is to be created

Returns:Vector2f

left minus right in dest

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

translateback to summary
public Vector2f translate(float x, float y)

Translate a vector

Parameters
x:float

The translation in x

y:float

the translation in y

Returns:Vector2f

this