org.openmali.vecmath2
Class Vector3f

java.lang.Object
  extended by org.openmali.vecmath2.TupleNf<Tuple3f>
      extended by org.openmali.vecmath2.Tuple3f
          extended by org.openmali.vecmath2.Vector3f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, TupleInterface<Tuple3f>, VectorInterface<Tuple3f,Vector3f>

public class Vector3f
extends Tuple3f
implements java.io.Externalizable, VectorInterface<Tuple3f,Vector3f>

A simple 3-dimensional float-Vector implementation. Inspired by Kenji Hiranabe's Vector3f implementation

See Also:
Serialized Form

Field Summary
static Vector3f NEGATIVE_X_AXIS
           
static Vector3f NEGATIVE_Y_AXIS
           
static Vector3f NEGATIVE_Z_AXIS
           
static Vector3f POSITIVE_X_AXIS
           
static Vector3f POSITIVE_Y_AXIS
           
static Vector3f POSITIVE_Z_AXIS
           
static Vector3f ZERO
           
 
Fields inherited from class org.openmali.vecmath2.TupleNf
isDirty, roTrick, values
 
Constructor Summary
  Vector3f()
          Creates a new Vector3f instance.
protected Vector3f(boolean readOnly)
          Creates a new Vector3f instance.
protected Vector3f(boolean readOnly, float[] values, boolean[] isDirty, boolean copy)
          Creates a new Vector3f instance.
protected Vector3f(boolean readOnly, float x, float y, float z)
          Creates a new Vector3f instance.
protected Vector3f(boolean readOnly, Tuple3f tuple)
          Creates a new Vector3f instance.
  Vector3f(float[] values)
          Creates a new Vector3f instance.
  Vector3f(float x, float y, float z)
          Creates a new Vector3f instance.
  Vector3f(Tuple3f tuple)
          Creates a new Vector3f instance.
 
Method Summary
 float angle(Vector3f v2)
          Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
 Vector3f asReadOnly()
          
 Vector3f clone()
          Creates and returns a copy of this object.
 Vector3f cross(Vector3f v1, Vector3f v2)
          Sets this vector to be the vector cross product of vectors v1 and v2.
 float dot(Vector3f v2)
          Computes the dot product of the this vector and vector v2.
static Vector3f fromPool()
          Allocates an Vector3f instance from the pool.
static Vector3f fromPool(float x, float y, float z)
          Allocates an Vector3f instance from the pool.
static Vector3f fromPool(Tuple3f tuple)
          Allocates an Vector3f instance from the pool.
 Vector3f getReadOnly()
          
 float length()
          
 float lengthSquared()
          
static Vector3f newReadOnly()
          Creates a new Vector3f instance.
static Vector3f newReadOnly(float[] values)
          Creates a new Vector3f instance.
static Vector3f newReadOnly(float x, float y, float z)
          Creates a new Vector3f instance.
static Vector3f newReadOnly(Tuple3f tuple)
          Creates a new Vector3f instance.
 Vector3f normalize()
          Normalizes this vector in place.
 Vector3f normalize(Vector3f vector)
          Sets the value of this vector to the normalization of vector v1.
static void toPool(Vector3f o)
          Stores the given Vector3f instance in the pool.
 
Methods inherited from class org.openmali.vecmath2.Tuple3f
add, addX, addY, addZ, div, divX, divY, divZ, equals, getX, getY, getZ, mul, mulX, mulY, mulZ, scale, set, setX, setY, setZ, sub, subX, subY, subZ, toPool, x, x, y, y, z, z
 
Methods inherited from class org.openmali.vecmath2.TupleNf
absolute, absolute, add, add, addValue, clamp, clamp, clampMax, clampMax, clampMin, clampMin, deserialize, div, divValue, epsilonEquals, equals, fill, get, get, get, getSerializationBufferSize, getSize, getValue, hashCode, interpolate, interpolate, isDirty, isReadOnly, mul, mulValue, negate, negate, readExternal, readFromBuffer, readFromBuffer, readFromBuffer, readFromBuffer, round, round, scale, scale, scaleAdd, scaleAdd, serialize, set, set, set, setClean, setValue, setZero, sub, sub, subValue, toString, writeExternal, writeToBuffer, writeToBuffer, writeToBuffer, writeToBuffer
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.openmali.vecmath2.TupleInterface
absolute, absolute, add, add, addValue, clamp, clamp, clampMax, clampMax, clampMin, clampMin, div, divValue, epsilonEquals, fill, get, get, get, getSize, getValue, interpolate, interpolate, isDirty, isReadOnly, mul, mulValue, negate, negate, round, round, scale, scale, scaleAdd, scaleAdd, set, set, set, setClean, setValue, setZero, sub, sub, subValue
 

Field Detail

ZERO

public static final Vector3f ZERO

POSITIVE_X_AXIS

public static final Vector3f POSITIVE_X_AXIS

NEGATIVE_X_AXIS

public static final Vector3f NEGATIVE_X_AXIS

POSITIVE_Y_AXIS

public static final Vector3f POSITIVE_Y_AXIS

NEGATIVE_Y_AXIS

public static final Vector3f NEGATIVE_Y_AXIS

POSITIVE_Z_AXIS

public static final Vector3f POSITIVE_Z_AXIS

NEGATIVE_Z_AXIS

public static final Vector3f NEGATIVE_Z_AXIS
Constructor Detail

Vector3f

protected Vector3f(boolean readOnly,
                   float x,
                   float y,
                   float z)
Creates a new Vector3f instance.

Parameters:
readOnly -
x - the x element to use
y - the y element to use
z - the z element to use

Vector3f

protected Vector3f(boolean readOnly,
                   float[] values,
                   boolean[] isDirty,
                   boolean copy)
Creates a new Vector3f instance.

Parameters:
readOnly -
values - the values array (must be at least size 3)
isDirty - the isDirty-value
copy - copy the array?

Vector3f

protected Vector3f(boolean readOnly,
                   Tuple3f tuple)
Creates a new Vector3f instance.

Parameters:
readOnly -
tuple - the Tuple3f to copy the values from

Vector3f

protected Vector3f(boolean readOnly)
Creates a new Vector3f instance.

Parameters:
readOnly -

Vector3f

public Vector3f(float x,
                float y,
                float z)
Creates a new Vector3f instance.

Parameters:
x - the x element to use
y - the y element to use
z - the z element to use

Vector3f

public Vector3f(float[] values)
Creates a new Vector3f instance.

Parameters:
values - the values array (must be at least size 3)

Vector3f

public Vector3f(Tuple3f tuple)
Creates a new Vector3f instance.

Parameters:
tuple - the Tuple3f to copy the values from

Vector3f

public Vector3f()
Creates a new Vector3f instance.

Method Detail

lengthSquared

public final float lengthSquared()

Specified by:
lengthSquared in interface VectorInterface<Tuple3f,Vector3f>
Returns:
the squared length of this vector

length

public final float length()

Specified by:
length in interface VectorInterface<Tuple3f,Vector3f>
Returns:
the length of this vector

normalize

public final Vector3f normalize()
Normalizes this vector in place.

Specified by:
normalize in interface VectorInterface<Tuple3f,Vector3f>
Returns:
itself

normalize

public final Vector3f normalize(Vector3f vector)
Sets the value of this vector to the normalization of vector v1.

Specified by:
normalize in interface VectorInterface<Tuple3f,Vector3f>
Parameters:
vector - the un-normalized vector
Returns:
itself

cross

public final Vector3f cross(Vector3f v1,
                            Vector3f v2)
Sets this vector to be the vector cross product of vectors v1 and v2.

Specified by:
cross in interface VectorInterface<Tuple3f,Vector3f>
Parameters:
v1 - the first vector
v2 - the second vector
Returns:
itself

dot

public final float dot(Vector3f v2)
Computes the dot product of the this vector and vector v2.

Specified by:
dot in interface VectorInterface<Tuple3f,Vector3f>
Parameters:
v2 - the other vector

angle

public final float angle(Vector3f v2)
Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].

Specified by:
angle in interface VectorInterface<Tuple3f,Vector3f>
Parameters:
v2 - the other vector
Returns:
the angle in radians in the range [0,PI]

clone

public Vector3f clone()
Creates and returns a copy of this object.

Overrides:
clone in class Tuple3f
Returns:
a clone of this instance.
See Also:
Cloneable

asReadOnly

public Vector3f asReadOnly()

Overrides:
asReadOnly in class Tuple3f
Returns:
a new instance sharing the values array with this instance. The new instance is read-only. Changes to this instance will be reflected in the new read-only-instance.
See Also:
TupleNf.getReadOnly()

getReadOnly

public Vector3f getReadOnly()

Overrides:
getReadOnly in class Tuple3f
Returns:
a single instance sharing the values array with this instance (one unique instance per 'master-instance'). The instance is read-only. Changes to this instance will be reflected in the read-only-instance.
See Also:
TupleNf.asReadOnly()

newReadOnly

public static Vector3f newReadOnly(float x,
                                   float y,
                                   float z)
Creates a new Vector3f instance.

Parameters:
x - the x element to use
y - the y element to use
z - the z element to use

newReadOnly

public static Vector3f newReadOnly(float[] values)
Creates a new Vector3f instance.

Parameters:
values - the values array (must be at least size 3)

newReadOnly

public static Vector3f newReadOnly(Tuple3f tuple)
Creates a new Vector3f instance.

Parameters:
tuple - the Tuple3f to copy the values from

newReadOnly

public static Vector3f newReadOnly()
Creates a new Vector3f instance.


fromPool

public static Vector3f fromPool()
Allocates an Vector3f instance from the pool.


fromPool

public static Vector3f fromPool(float x,
                                float y,
                                float z)
Allocates an Vector3f instance from the pool.


fromPool

public static Vector3f fromPool(Tuple3f tuple)
Allocates an Vector3f instance from the pool.


toPool

public static void toPool(Vector3f o)
Stores the given Vector3f instance in the pool.

Parameters:
o -