org.openmali.vecmath2
Class Vector3d

java.lang.Object
  extended by org.openmali.vecmath2.TupleNd<Tuple3d>
      extended by org.openmali.vecmath2.Tuple3d
          extended by org.openmali.vecmath2.Vector3d
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Vector3d
extends Tuple3d
implements java.io.Externalizable

A simple 3-dimensional double-Vector implementation. Inspired by Kenji Hiranabe's Vector3d implementation

See Also:
Serialized Form

Field Summary
static Vector3d NEGATIVE_X_AXIS
           
static Vector3d NEGATIVE_Y_AXIS
           
static Vector3d NEGATIVE_Z_AXIS
           
static Vector3d POSITIVE_X_AXIS
           
static Vector3d POSITIVE_Y_AXIS
           
static Vector3d POSITIVE_Z_AXIS
           
static Vector3d ZERO
           
 
Fields inherited from class org.openmali.vecmath2.TupleNd
isDirty, roTrick, values
 
Constructor Summary
  Vector3d()
          Creates a new Vector3d instance.
protected Vector3d(boolean readOnly)
          Creates a new Vector3d instance.
protected Vector3d(boolean readOnly, double[] values, boolean[] isDirty, boolean copy)
          Creates a new Vector3d instance.
protected Vector3d(boolean readOnly, double x, double y, double z)
          Creates a new Vector3d instance.
protected Vector3d(boolean readOnly, Tuple3d tuple)
          Creates a new Vector3d instance.
  Vector3d(double[] values)
          Creates a new Vector3d instance.
  Vector3d(double x, double y, double z)
          Creates a new Vector3d instance.
  Vector3d(Tuple3d tuple)
          Creates a new Vector3d instance.
 
Method Summary
 double angle(Vector3d v2)
          
 Vector3d asReadOnly()
          
 Vector3d cross(Vector3d v1, Vector3d v2)
          
 double dot(Vector3d v2)
          
static Vector3d fromPool()
          Allocates an Vector3d instance from the pool.
static Vector3d fromPool(double x, double y, double z)
          Allocates an Vector3d instance from the pool.
static Vector3d fromPool(Tuple3d tuple)
          Allocates an Vector3d instance from the pool.
 Vector3d getReadOnly()
          
 double length()
          
 double lengthSquared()
          
static Vector3d newReadOnly()
          Creates a new Vector3d instance.
static Vector3d newReadOnly(double[] values)
          Creates a new Vector3d instance.
static Vector3d newReadOnly(double x, double y, double z)
          Creates a new Vector3d instance.
static Vector3d newReadOnly(Tuple3d tuple)
          Creates a new Vector3d instance.
 Vector3d normalize()
          
 Vector3d normalize(Vector3d vector)
          
static void toPool(Vector3d o)
          Stores the given Vector3d instance in the pool.
 
Methods inherited from class org.openmali.vecmath2.Tuple3d
add, addX, addY, addZ, clone, 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.TupleNd
absolute, absolute, add, add, addValue, clamp, clamp, clampMax, clampMax, clampMin, clampMin, deserialize, div, divValue, epsilonEquals, equals, fill, get, get, getSerializationBufferSize, getSize, getValue, hashCode, interpolate, interpolate, isDirty, isReadOnly, mul, mulValue, negate, negate, readExternal, round, round, scale, scale, scaleAdd, scaleAdd, serialize, set, set, setClean, setValue, setZero, sub, sub, subValue, toString, writeExternal, 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
 

Field Detail

ZERO

public static final Vector3d ZERO

POSITIVE_X_AXIS

public static final Vector3d POSITIVE_X_AXIS

NEGATIVE_X_AXIS

public static final Vector3d NEGATIVE_X_AXIS

POSITIVE_Y_AXIS

public static final Vector3d POSITIVE_Y_AXIS

NEGATIVE_Y_AXIS

public static final Vector3d NEGATIVE_Y_AXIS

POSITIVE_Z_AXIS

public static final Vector3d POSITIVE_Z_AXIS

NEGATIVE_Z_AXIS

public static final Vector3d NEGATIVE_Z_AXIS
Constructor Detail

Vector3d

protected Vector3d(boolean readOnly,
                   double x,
                   double y,
                   double z)
Creates a new Vector3d instance.

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

Vector3d

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

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

Vector3d

protected Vector3d(boolean readOnly,
                   Tuple3d tuple)
Creates a new Vector3d instance.

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

Vector3d

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

Parameters:
readOnly -

Vector3d

public Vector3d(double x,
                double y,
                double z)
Creates a new Vector3d instance.

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

Vector3d

public Vector3d(double[] values)
Creates a new Vector3d instance.

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

Vector3d

public Vector3d(Tuple3d tuple)
Creates a new Vector3d instance.

Parameters:
tuple - the Tuple3d to copy the values from

Vector3d

public Vector3d()
Creates a new Vector3d instance.

Method Detail

lengthSquared

public final double lengthSquared()


length

public final double length()


normalize

public final Vector3d normalize()


normalize

public final Vector3d normalize(Vector3d vector)


cross

public final Vector3d cross(Vector3d v1,
                            Vector3d v2)


dot

public final double dot(Vector3d v2)


angle

public final double angle(Vector3d v2)


asReadOnly

public Vector3d asReadOnly()

Overrides:
asReadOnly in class Tuple3d
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:
TupleNd.getReadOnly()

getReadOnly

public Vector3d getReadOnly()

Overrides:
getReadOnly in class Tuple3d
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:
TupleNd.asReadOnly()

newReadOnly

public static Vector3d newReadOnly(double x,
                                   double y,
                                   double z)
Creates a new Vector3d instance.

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

newReadOnly

public static Vector3d newReadOnly(double[] values)
Creates a new Vector3d instance.

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

newReadOnly

public static Vector3d newReadOnly(Tuple3d tuple)
Creates a new Vector3d instance.

Parameters:
tuple - the Tuple3d to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

public static Vector3d fromPool(Tuple3d tuple)
Allocates an Vector3d instance from the pool.


toPool

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

Parameters:
o -