org.openmali.vecmath2
Class Tuple3d

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

public class Tuple3d
extends TupleNd<Tuple3d>
implements java.io.Externalizable

A simple three-dimensional tuple implementation. Inspired by Kenji Hiranabe's Tuple3d implementation

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.vecmath2.TupleNd
isDirty, roTrick, values
 
Constructor Summary
  Tuple3d()
          Creates a new Tuple3d instance.
protected Tuple3d(boolean readOnly)
          Creates a new Tuple3d instance.
protected Tuple3d(boolean readOnly, double[] values, boolean[] isDirty, boolean copy)
          Creates a new Tuple3d instance.
protected Tuple3d(boolean readOnly, double x, double y, double z)
          Creates a new Tuple3d instance.
protected Tuple3d(boolean readOnly, Tuple3d that)
          Creates a new Tuple3d instance.
  Tuple3d(double[] values)
          Creates a new Tuple3d instance.
  Tuple3d(double x, double y, double z)
          Creates a new Tuple3d instance.
  Tuple3d(Tuple3d that)
          Creates a new Tuple3d instance.
 
Method Summary
 Tuple3d add(double x, double y, double z)
          Adds the given parameters to this tuple's values.
 Tuple3d addX(double v)
          Adds v to this tuple's x value.
 Tuple3d addY(double v)
          Adds v to this tuple's y value.
 Tuple3d addZ(double v)
          Adds v to this tuple's z value.
 Tuple3d asReadOnly()
          
 Tuple3d clone()
          Creates and returns a copy of this object.
 Tuple3d div(double vx, double vy, double vz)
          Divides this tuple's values by vx, vy, vz.
 Tuple3d divX(double v)
          Divides this tuple's x value by v.
 Tuple3d divY(double v)
          Divides this tuple's y value by v.
 Tuple3d divZ(double v)
          Divides this tuple's z value by v.
 boolean equals(java.lang.Object o)
          Returns true if the Object t1 is of type Tuple3d and all of the data members of t1 are equal to the corresponding data members in this Tuple3d.
static Tuple3d fromPool()
          Allocates an Tuple3d instance from the pool.
static Tuple3d fromPool(double x, double y, double z)
          Allocates an Tuple3d instance from the pool.
static Tuple3d fromPool(Tuple3d tuple)
          Allocates an Tuple3d instance from the pool.
 Tuple3d getReadOnly()
          
 double getX()
           
 double getY()
           
 double getZ()
           
 Tuple3d mul(double vx, double vy, double vz)
          Multiplies this tuple's values with vx, vy, vz.
 Tuple3d mulX(double v)
          Multiplies this tuple's x value with v.
 Tuple3d mulY(double v)
          Multiplies this tuple's y value with v.
 Tuple3d mulZ(double v)
          Multiplies this tuple's z value with v.
static Tuple3d newReadOnly()
          Creates a new Tuple3d instance.
static Tuple3d newReadOnly(double[] values)
          Creates a new Tuple3d instance.
static Tuple3d newReadOnly(double x, double y, double z)
          Creates a new Tuple3d instance.
static Tuple3d newReadOnly(Tuple3d tuple)
          Creates a new Tuple3d instance.
 Tuple3d scale(double factorX, double factorY, double factorZ)
          Sets the value of this tuple to the scalar multiplication of tuple t1.
 Tuple3d set(double x, double y, double z)
          Sets all three values of this Tuple to the specified ones.
 Tuple3d setX(double x)
          Sets the value of the x-element of this tuple.
 Tuple3d setY(double y)
          Sets the value of the y-element of this tuple.
 Tuple3d setZ(double z)
          Sets the value of the z-element of this tuple.
 Tuple3d sub(double x, double y, double z)
          Subtracts the given parameters from this tuple's values.
 Tuple3d subX(double v)
          Subtracts v from this tuple's x value.
 Tuple3d subY(double v)
          Subtracts v from this tuple's y value.
 Tuple3d subZ(double v)
          Subtracts v from this tuple's z value.
static void toPool(Tuple3d o)
          Stores the given Tuple3d instance in the pool.
 double x()
           
 Tuple3d x(double x)
          Sets the value of the x-element of this tuple.
 double y()
           
 Tuple3d y(double y)
          Sets the value of the y-element of this tuple.
 double z()
           
 Tuple3d z(double z)
          Sets the value of the z-element of this tuple.
 
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
 

Constructor Detail

Tuple3d

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

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

Tuple3d

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

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

Tuple3d

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

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

Tuple3d

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

Parameters:
readOnly -

Tuple3d

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

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

Tuple3d

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

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

Tuple3d

public Tuple3d(Tuple3d that)
Creates a new Tuple3d instance.

Parameters:
that - the Tuple3d to copy the values from

Tuple3d

public Tuple3d()
Creates a new Tuple3d instance.

Method Detail

set

public final Tuple3d set(double x,
                         double y,
                         double z)
Sets all three values of this Tuple to the specified ones.

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

setX

public final Tuple3d setX(double x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

setY

public final Tuple3d setY(double y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

setZ

public final Tuple3d setZ(double z)
Sets the value of the z-element of this tuple.

Parameters:
z -
Returns:
itself

getX

public final double getX()
Returns:
the value of the x-element of this tuple.

getY

public final double getY()
Returns:
the value of the y-element of this tuple.

getZ

public final double getZ()
Returns:
the value of the z-element of this tuple.

x

public final Tuple3d x(double x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

y

public final Tuple3d y(double y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

z

public final Tuple3d z(double z)
Sets the value of the z-element of this tuple.

Parameters:
z -
Returns:
itself

x

public final double x()
Returns:
the value of the x-element of this tuple.

y

public final double y()
Returns:
the value of the y-element of this tuple.

z

public final double z()
Returns:
the value of the z-element of this tuple.

addX

public final Tuple3d addX(double v)
Adds v to this tuple's x value.

Parameters:
v -
Returns:
itself

addY

public final Tuple3d addY(double v)
Adds v to this tuple's y value.

Parameters:
v -
Returns:
itself

addZ

public final Tuple3d addZ(double v)
Adds v to this tuple's z value.

Parameters:
v -
Returns:
itself

add

public final Tuple3d add(double x,
                         double y,
                         double z)
Adds the given parameters to this tuple's values.

Parameters:
x -
y -
z -
Returns:
itself

subX

public final Tuple3d subX(double v)
Subtracts v from this tuple's x value.

Parameters:
v -
Returns:
itself

subY

public final Tuple3d subY(double v)
Subtracts v from this tuple's y value.

Parameters:
v -
Returns:
itself

subZ

public final Tuple3d subZ(double v)
Subtracts v from this tuple's z value.

Parameters:
v -
Returns:
itself

sub

public final Tuple3d sub(double x,
                         double y,
                         double z)
Subtracts the given parameters from this tuple's values.

Parameters:
x -
y -
z -
Returns:
itself

mulX

public final Tuple3d mulX(double v)
Multiplies this tuple's x value with v.

Parameters:
v -
Returns:
itself

mulY

public final Tuple3d mulY(double v)
Multiplies this tuple's y value with v.

Parameters:
v -
Returns:
itself

mulZ

public final Tuple3d mulZ(double v)
Multiplies this tuple's z value with v.

Parameters:
v -
Returns:
itself

mul

public final Tuple3d mul(double vx,
                         double vy,
                         double vz)
Multiplies this tuple's values with vx, vy, vz.

Parameters:
vx -
vy -
vz -
Returns:
itself

divX

public final Tuple3d divX(double v)
Divides this tuple's x value by v.

Parameters:
v -
Returns:
itself

divY

public final Tuple3d divY(double v)
Divides this tuple's y value by v.

Parameters:
v -
Returns:
itself

divZ

public final Tuple3d divZ(double v)
Divides this tuple's z value by v.

Parameters:
v -
Returns:
itself

div

public final Tuple3d div(double vx,
                         double vy,
                         double vz)
Divides this tuple's values by vx, vy, vz.

Parameters:
vx -
vy -
vz -
Returns:
itself

scale

public final Tuple3d scale(double factorX,
                           double factorY,
                           double factorZ)
Sets the value of this tuple to the scalar multiplication of tuple t1.

Parameters:
factorX -
factorY -
factorZ -
Returns:
itself

asReadOnly

public Tuple3d asReadOnly()

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

Specified by:
getReadOnly in class TupleNd<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()

equals

public boolean equals(java.lang.Object o)
Returns true if the Object t1 is of type Tuple3d and all of the data members of t1 are equal to the corresponding data members in this Tuple3d.

Overrides:
equals in class TupleNd<Tuple3d>
Parameters:
o - the Object with which the comparison is made
Returns:
true or false

clone

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

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
java.lang.OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

newReadOnly

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

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

newReadOnly

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

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

newReadOnly

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

Parameters:
tuple - the Tuple3d to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

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


toPool

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

Parameters:
o -