org.openmali.vecmath2
Class Tuple4i

java.lang.Object
  extended by org.openmali.vecmath2.TupleNi<Tuple4i>
      extended by org.openmali.vecmath2.Tuple4i
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Tuple4i
extends TupleNi<Tuple4i>

A simple four-dimensional tuple implementation. Inspired by Kenji Hiranabe's Tuple4i implementation

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.vecmath2.TupleNi
isDirty, N, roTrick, values
 
Constructor Summary
  Tuple4i()
          Creates a new Tuple4i instance.
protected Tuple4i(boolean readOnly)
          Creates a new Tuple4i instance.
protected Tuple4i(boolean readOnly, int[] values, boolean[] isDirty, boolean copy)
          Creates a new Tuple4i instance.
protected Tuple4i(boolean readOnly, int x, int y, int z, int w)
          Creates a new Tuple4i instance.
protected Tuple4i(boolean readOnly, Tuple4i that)
          Creates a new Tuple4i instance.
  Tuple4i(int[] values)
          Creates a new Tuple4i instance.
  Tuple4i(int x, int y, int z, int w)
          Creates a new Tuple4i instance.
  Tuple4i(Tuple4i that)
          Creates a new Tuple4i instance.
 
Method Summary
 Tuple4i add(int x, int y, int z, int w)
          Adds the given parameters to this tuple's values.
 Tuple4i addW(int v)
          Adds v to this tuple's w value.
 Tuple4i addX(int v)
          Adds v to this tuple's x value.
 Tuple4i addY(int v)
          Adds v to this tuple's y value.
 Tuple4i addZ(int v)
          Adds v to this tuple's z value.
 Tuple4i asReadOnly()
          
 Tuple4i clone()
          Creates and returns a copy of this object.
 Tuple4i div(int vx, int vy, int vz, int vw)
          Divides this tuple's values by vx, vy, vz.
 Tuple4i divW(int v)
          Divides this tuple's w value by v.
 Tuple4i divX(int v)
          Divides this tuple's x value by v.
 Tuple4i divY(int v)
          Divides this tuple's y value by v.
 Tuple4i divZ(int v)
          Divides this tuple's z value by v.
 boolean equals(java.lang.Object tuple2)
          Returns true if the Object t1 is of type Tuple3f and all of the data members of t1 are equal to the corresponding data members in this Tuple2f.
 boolean equals(Tuple4i tuple2)
          Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.
static Tuple4i fromPool()
          Allocates an Tuple4i instance from the pool.
static Tuple4i fromPool(int x, int y, int z, int w)
          Allocates an Tuple4i instance from the pool.
static Tuple4i fromPool(Tuple4i tuple)
          Allocates an Tuple4i instance from the pool.
 Tuple4i getReadOnly()
          
 int getW()
           
 int getX()
           
 int getY()
           
 int getZ()
           
 int hashCode()
          Returns a hash number based on the data values in this object.
 Tuple4i mul(int vx, int vy, int vz, int vw)
          Multiplies this tuple's values with vx, vy.
 Tuple4i mulW(int v)
          Multiplies this tuple's w value with v.
 Tuple4i mulX(int v)
          Multiplies this tuple's x value with v.
 Tuple4i mulY(int v)
          Multiplies this tuple's y value with v.
 Tuple4i mulZ(int v)
          Multiplies this tuple's z value with v.
static Tuple4i newReadOnly()
          Creates a new Tuple4i instance.
static Tuple4i newReadOnly(int[] values)
          Creates a new Tuple4i instance.
static Tuple4i newReadOnly(int x, int y, int z, int w)
          Creates a new Tuple4i instance.
static Tuple4i newReadOnly(Tuple4i tuple)
          Creates a new Tuple4i instance.
 Tuple4i scale(int factorX, int factorY, int factorZ, int factorW)
          Sets the value of this tuple to the scalar multiplication of tuple t1.
 Tuple4i setValues(int x, int y, int z, int w)
          Sets all three values of this Tuple to the specified ones.
 Tuple4i setW(int w)
          Sets the value of the w-element of this tuple.
 Tuple4i setX(int x)
          Sets the value of the x-element of this tuple.
 Tuple4i setY(int y)
          Sets the value of the y-element of this tuple.
 Tuple4i setZ(int z)
          Sets the value of the z-element of this tuple.
 Tuple4i sub(int x, int y, int z, int w)
          Subtracts the given parameters from this tuple's values.
 Tuple4i subW(int v)
          Subtracts v from this tuple's w value.
 Tuple4i subX(int v)
          Subtracts v from this tuple's x value.
 Tuple4i subY(int v)
          Subtracts v from this tuple's y value.
 Tuple4i subZ(int v)
          Subtracts v from this tuple's z value.
static void toPool(Tuple4i o)
          Stores the given Tuple4i instance in the pool.
 java.lang.String toString()
          Returns a string that contains the values of this Tuple2f.
 int w()
           
 Tuple4i w(int w)
          Sets the value of the w-element of this tuple.
 int x()
           
 Tuple4i x(int x)
          Sets the value of the x-element of this tuple.
 int y()
           
 Tuple4i y(int y)
          Sets the value of the y-element of this tuple.
 int z()
           
 Tuple4i z(int z)
          Sets the value of the z-element of this tuple.
 
Methods inherited from class org.openmali.vecmath2.TupleNi
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, deserialize, get, get, get, getSerializationBufferSize, getSize, getValue, isDirty, isReadOnly, negate, negate, readExternal, scale, scale, scaleAdd, scaleAdd, serialize, set, set, set, setClean, setValue, setZero, sub, sub, writeExternal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple4i

protected Tuple4i(boolean readOnly,
                  int x,
                  int y,
                  int z,
                  int w)
Creates a new Tuple4i instance.

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

Tuple4i

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

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

Tuple4i

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

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

Tuple4i

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

Parameters:
readOnly -

Tuple4i

public Tuple4i(int x,
               int y,
               int z,
               int w)
Creates a new Tuple4i instance.

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

Tuple4i

public Tuple4i(int[] values)
Creates a new Tuple4i instance.

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

Tuple4i

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

Parameters:
that - the Tuple4i to copy the values from

Tuple4i

public Tuple4i()
Creates a new Tuple4i instance.

Method Detail

setX

public final Tuple4i setX(int x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

setY

public final Tuple4i setY(int y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

setZ

public final Tuple4i setZ(int z)
Sets the value of the z-element of this tuple.

Parameters:
z -
Returns:
itself

setW

public final Tuple4i setW(int w)
Sets the value of the w-element of this tuple.

Parameters:
w -
Returns:
itself

getX

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

getY

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

getZ

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

getW

public final int getW()
Returns:
the value of the w-element of this tuple.

x

public final Tuple4i x(int x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

y

public final Tuple4i y(int y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

z

public final Tuple4i z(int z)
Sets the value of the z-element of this tuple.

Parameters:
z -
Returns:
itself

w

public final Tuple4i w(int w)
Sets the value of the w-element of this tuple.

Parameters:
w -
Returns:
itself

x

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

y

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

z

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

w

public final int w()
Returns:
the value of the w-element of this tuple.

setValues

public final Tuple4i setValues(int x,
                               int y,
                               int z,
                               int w)
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
w - the w element to use
Returns:
itself

addX

public final Tuple4i addX(int v)
Adds v to this tuple's x value.

Parameters:
v -
Returns:
itself

addY

public final Tuple4i addY(int v)
Adds v to this tuple's y value.

Parameters:
v -
Returns:
itself

addZ

public final Tuple4i addZ(int v)
Adds v to this tuple's z value.

Parameters:
v -
Returns:
itself

addW

public final Tuple4i addW(int v)
Adds v to this tuple's w value.

Parameters:
v -
Returns:
itself

add

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

Parameters:
x -
y -
z -
w -
Returns:
itself

subX

public final Tuple4i subX(int v)
Subtracts v from this tuple's x value.

Parameters:
v -
Returns:
itself

subY

public final Tuple4i subY(int v)
Subtracts v from this tuple's y value.

Parameters:
v -
Returns:
itself

subZ

public final Tuple4i subZ(int v)
Subtracts v from this tuple's z value.

Parameters:
v -
Returns:
itself

subW

public final Tuple4i subW(int v)
Subtracts v from this tuple's w value.

Parameters:
v -
Returns:
itself

sub

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

Parameters:
x -
y -
z -
w -
Returns:
itself

mulX

public final Tuple4i mulX(int v)
Multiplies this tuple's x value with v.

Parameters:
v -
Returns:
itself

mulY

public final Tuple4i mulY(int v)
Multiplies this tuple's y value with v.

Parameters:
v -
Returns:
itself

mulZ

public final Tuple4i mulZ(int v)
Multiplies this tuple's z value with v.

Parameters:
v -
Returns:
itself

mulW

public final Tuple4i mulW(int v)
Multiplies this tuple's w value with v.

Parameters:
v -
Returns:
itself

mul

public final Tuple4i mul(int vx,
                         int vy,
                         int vz,
                         int vw)
Multiplies this tuple's values with vx, vy.

Parameters:
vx -
vy -
vz -
vw -
Returns:
itself

divX

public final Tuple4i divX(int v)
Divides this tuple's x value by v.

Parameters:
v -
Returns:
itself

divY

public final Tuple4i divY(int v)
Divides this tuple's y value by v.

Parameters:
v -
Returns:
itself

divZ

public final Tuple4i divZ(int v)
Divides this tuple's z value by v.

Parameters:
v -
Returns:
itself

divW

public final Tuple4i divW(int v)
Divides this tuple's w value by v.

Parameters:
v -
Returns:
itself

div

public final Tuple4i div(int vx,
                         int vy,
                         int vz,
                         int vw)
Divides this tuple's values by vx, vy, vz.

Parameters:
vx -
vy -
vz -
vw -
Returns:
itself

scale

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

Parameters:
factorX -
factorY -
factorZ -
factorW -
Returns:
itself

asReadOnly

public Tuple4i asReadOnly()

Specified by:
asReadOnly in class TupleNi<Tuple4i>
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:
TupleNi.getReadOnly()

getReadOnly

public Tuple4i getReadOnly()

Specified by:
getReadOnly in class TupleNi<Tuple4i>
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:
TupleNi.asReadOnly()

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (ie, returns true for equals(Tuple3f) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.

Specified by:
hashCode in class TupleNi<Tuple4i>

equals

public boolean equals(Tuple4i tuple2)
Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.

Overrides:
equals in class TupleNi<Tuple4i>
Parameters:
tuple2 - The vector with which the comparison is made.
Returns:
true or false

equals

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

Overrides:
equals in class TupleNi<Tuple4i>
Parameters:
tuple2 - the Object with which the comparison is made
Returns:
true or false

toString

public java.lang.String toString()
Returns a string that contains the values of this Tuple2f. The form is (x, y).

Specified by:
toString in class TupleNi<Tuple4i>
Returns:
the String representation

clone

public Tuple4i 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 Tuple4i newReadOnly(int x,
                                  int y,
                                  int z,
                                  int w)
Creates a new Tuple4i instance.

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

newReadOnly

public static Tuple4i newReadOnly(int[] values)
Creates a new Tuple4i instance.

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

newReadOnly

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

Parameters:
tuple - the Tuple4i to copy the values from

newReadOnly

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


fromPool

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


fromPool

public static Tuple4i fromPool(int x,
                               int y,
                               int z,
                               int w)
Allocates an Tuple4i instance from the pool.


fromPool

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


toPool

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

Parameters:
o -