org.lwjgl.util.vector
Class Vector4f

java.lang.Object
  extended by org.lwjgl.util.vector.Vector
      extended by org.lwjgl.util.vector.Vector4f
All Implemented Interfaces:
java.io.Serializable, ReadableVector, ReadableVector2f, ReadableVector3f, ReadableVector4f, WritableVector2f, WritableVector3f, WritableVector4f

public class Vector4f
extends Vector
implements java.io.Serializable, ReadableVector4f, WritableVector4f

Holds a 4-tuple vector.

Version:
$Revision: 2983 $ $Id: Vector4f.java 2983 2008-04-07 18:36:09Z matzon $
Author:
cix_foo
See Also:
Serialized Form

Field Summary
 float w
           
 float x
           
 float y
           
 float z
           
 
Constructor Summary
Vector4f()
          Constructor for Vector4f.
Vector4f(float x, float y, float z, float w)
          Constructor
Vector4f(ReadableVector4f src)
          Constructor
 
Method Summary
static Vector4f add(Vector4f left, Vector4f right, Vector4f dest)
          Add a vector to another vector and place the result in a destination vector.
static float angle(Vector4f a, Vector4f b)
          Calculate the angle between two vectors, in radians
static float dot(Vector4f left, Vector4f right)
          The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w
 float getW()
           
 float getX()
           
 float getY()
           
 float getZ()
           
 float lengthSquared()
           
 Vector load(java.nio.FloatBuffer buf)
          Load this vector from a FloatBuffer
 Vector negate()
          Negate a vector
 Vector4f negate(Vector4f dest)
          Negate a vector and place the result in a destination vector.
 Vector4f normalise(Vector4f dest)
          Normalise this vector and place the result in another vector.
 Vector scale(float scale)
          Scale this vector
 void set(float x, float y)
          Set the X,Y values
 void set(float x, float y, float z)
          Set the X,Y,Z values
 void set(float x, float y, float z, float w)
          Set the X,Y,Z,W values
 Vector4f set(ReadableVector4f src)
          Load from another Vector4f
 void setW(float w)
          Set W
 void setX(float x)
          Set X
 void setY(float y)
          Set Y
 void setZ(float z)
          Set Z
 Vector store(java.nio.FloatBuffer buf)
          Store this vector in a FloatBuffer
static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest)
          Subtract a vector from another vector and place the result in a destination vector.
 java.lang.String toString()
           
 Vector4f translate(float x, float y, float z, float w)
          Translate a vector
 
Methods inherited from class org.lwjgl.util.vector.Vector
length, normalise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.lwjgl.util.vector.ReadableVector
length
 

Field Detail

x

public float x

y

public float y

z

public float z

w

public float w
Constructor Detail

Vector4f

public Vector4f()
Constructor for Vector4f.


Vector4f

public Vector4f(ReadableVector4f src)
Constructor


Vector4f

public Vector4f(float x,
                float y,
                float z,
                float w)
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 interface WritableVector2f

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 interface WritableVector3f

set

public void set(float x,
                float y,
                float z,
                float w)
Description copied from interface: WritableVector4f
Set the X,Y,Z,W values

Specified by:
set in interface WritableVector4f

set

public Vector4f set(ReadableVector4f src)
Load from another Vector4f

Parameters:
src - The source vector
Returns:
this

lengthSquared

public float lengthSquared()
Specified by:
lengthSquared in interface ReadableVector
Specified by:
lengthSquared in class Vector
Returns:
the length squared of the vector

translate

public Vector4f translate(float x,
                          float y,
                          float z,
                          float w)
Translate a vector

Parameters:
x - The translation in x
y - the translation in y
Returns:
this

add

public static Vector4f add(Vector4f left,
                           Vector4f right,
                           Vector4f dest)
Add a vector to another vector and place the result in a destination vector.

Parameters:
left - The LHS vector
right - The RHS vector
dest - 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 Vector4f sub(Vector4f left,
                           Vector4f right,
                           Vector4f dest)
Subtract a vector from another vector and place the result in a destination vector.

Parameters:
left - The LHS vector
right - The RHS vector
dest - The destination vector, or null if a new vector is to be created
Returns:
left minus right in dest

negate

public Vector negate()
Negate a vector

Specified by:
negate in class Vector
Returns:
this

negate

public Vector4f negate(Vector4f 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 Vector4f normalise(Vector4f 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(Vector4f left,
                        Vector4f right)
The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w

Parameters:
left - The LHS vector
right - The RHS vector
Returns:
left dot right

angle

public static float angle(Vector4f a,
                          Vector4f b)
Calculate the angle between two vectors, in radians

Parameters:
a - A vector
b - The other vector
Returns:
the angle between the two vectors, in radians

load

public Vector load(java.nio.FloatBuffer buf)
Description copied from class: Vector
Load this vector from a FloatBuffer

Specified by:
load in class Vector
Parameters:
buf - The buffer to load it from, at the current position
Returns:
this

scale

public Vector scale(float scale)
Description copied from class: Vector
Scale this vector

Specified by:
scale in class Vector
Parameters:
scale - The scale factor
Returns:
this

store

public Vector store(java.nio.FloatBuffer buf)
Description copied from class: Vector
Store this vector in a FloatBuffer

Specified by:
store in interface ReadableVector
Specified by:
store in class Vector
Parameters:
buf - The buffer to store it in, at the current position
Returns:
this

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getX

public final float getX()
Specified by:
getX in interface ReadableVector2f
Returns:
x

getY

public final float getY()
Specified by:
getY in interface ReadableVector2f
Returns:
y

setX

public final void setX(float x)
Set X

Specified by:
setX in interface WritableVector2f
Parameters:
x -

setY

public final void setY(float y)
Set Y

Specified by:
setY in interface WritableVector2f
Parameters:
y -

setZ

public void setZ(float z)
Set Z

Specified by:
setZ in interface WritableVector3f
Parameters:
z -

getZ

public float getZ()
Specified by:
getZ in interface ReadableVector3f
Returns:
z

setW

public void setW(float w)
Set W

Specified by:
setW in interface WritableVector4f
Parameters:
w -

getW

public float getW()
Specified by:
getW in interface ReadableVector4f
Returns:
w


Copyright © 2002-2009 lwjgl.org. All Rights Reserved.