org.openmali.vecmath2
Class Tuple2f

java.lang.Object
  extended by org.openmali.vecmath2.TupleNf<Tuple2f>
      extended by org.openmali.vecmath2.Tuple2f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, TupleInterface<Tuple2f>
Direct Known Subclasses:
Point2f, Vector2f

public class Tuple2f
extends TupleNf<Tuple2f>
implements java.io.Externalizable, TupleInterface<Tuple2f>

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.vecmath2.TupleNf
isDirty, roTrick, values
 
Constructor Summary
  Tuple2f()
          Creates a new Tuple2f instance.
protected Tuple2f(boolean readOnly)
          Creates a new Tuple2f instance.
protected Tuple2f(boolean readOnly, float[] values, boolean[] isDirty, boolean copy)
          Creates a new Tuple2f instance.
protected Tuple2f(boolean readOnly, float x, float y)
          Creates a new Tuple2f instance.
protected Tuple2f(boolean readOnly, Tuple2f that)
          Creates a new Tuple2f instance.
  Tuple2f(float[] values)
          Creates a new Tuple2f instance.
  Tuple2f(float x, float y)
          Creates a new Tuple2f instance.
  Tuple2f(Tuple2f that)
          Creates a new Tuple2f instance.
 
Method Summary
 Tuple2f add(float x, float y)
          Adds the given parameters to this tuple's values.
 Tuple2f addX(float v)
          Adds v to this tuple's x value.
 Tuple2f addY(float v)
          Adds v to this tuple's y value.
 Tuple2f asReadOnly()
          
 Tuple2f clone()
          Creates and returns a copy of this object.
 Tuple2f div(float vx, float vy)
          Divides this tuple's values by vx, vy, vz.
 Tuple2f divX(float v)
          Divides this tuple's x value by v.
 Tuple2f divY(float v)
          Divides this tuple's y 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.
static Tuple2f fromPool()
          Allocates an Tuple2f instance from the pool.
static Tuple2f fromPool(float x, float y)
          Allocates an Tuple2f instance from the pool.
static Tuple2f fromPool(Tuple2f tuple)
          Allocates an Tuple2f instance from the pool.
 Tuple2f getReadOnly()
          
 float getX()
           
 float getY()
           
 Tuple2f mul(float vx, float vy)
          Multiplies this tuple's values with vx, vy.
 Tuple2f mulX(float v)
          Multiplies this tuple's x value with v.
 Tuple2f mulY(float v)
          Multiplies this tuple's y value with v.
static Tuple2f newReadOnly()
          Creates a new Tuple2f instance.
static Tuple2f newReadOnly(float[] values)
          Creates a new Tuple2f instance.
static Tuple2f newReadOnly(float x, float y)
          Creates a new Tuple2f instance.
static Tuple2f newReadOnly(Tuple2f tuple)
          Creates a new Tuple2f instance.
 Tuple2f scale(float factorX, float factorY)
          Sets the value of this tuple to the scalar multiplication of tuple t1.
 Tuple2f set(float x, float y)
          Sets all three values of this Tuple to the specified ones.
 Tuple2f setX(float x)
          Sets the value of the x-element of this tuple.
 Tuple2f setY(float y)
          Sets the value of the y-element of this tuple.
 Tuple2f sub(float x, float y)
          Subtracts the given parameters from this tuple's values.
 Tuple2f subX(float v)
          Subtracts v from this tuple's x value.
 Tuple2f subY(float v)
          Subtracts v from this tuple's y value.
static void toPool(Tuple2f o)
          Stores the given Tuple2f instance in the pool.
 float x()
           
 Tuple2f x(float x)
          Sets the value of the x-element of this tuple.
 float y()
           
 Tuple2f y(float y)
          Sets the value of the y-element of this tuple.
 
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
 

Constructor Detail

Tuple2f

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

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

Tuple2f

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

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

Tuple2f

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

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

Tuple2f

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

Parameters:
readOnly -

Tuple2f

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

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

Tuple2f

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

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

Tuple2f

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

Parameters:
that - the Tuple2f to copy the values from

Tuple2f

public Tuple2f()
Creates a new Tuple2f instance.

Method Detail

set

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

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

setX

public final Tuple2f setX(float x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

setY

public final Tuple2f setY(float y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

getX

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

getY

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

x

public final Tuple2f x(float x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

y

public final Tuple2f y(float y)
Sets the value of the y-element of this tuple.

Parameters:
y -
Returns:
itself

x

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

y

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

addX

public final Tuple2f addX(float v)
Adds v to this tuple's x value.

Parameters:
v -
Returns:
itself

addY

public final Tuple2f addY(float v)
Adds v to this tuple's y value.

Parameters:
v -
Returns:
itself

add

public final Tuple2f add(float x,
                         float y)
Adds the given parameters to this tuple's values.

Parameters:
x -
y -
Returns:
itself

subX

public final Tuple2f subX(float v)
Subtracts v from this tuple's x value.

Parameters:
v -
Returns:
itself

subY

public final Tuple2f subY(float v)
Subtracts v from this tuple's y value.

Parameters:
v -
Returns:
itself

sub

public final Tuple2f sub(float x,
                         float y)
Subtracts the given parameters from this tuple's values.

Parameters:
x -
y -
Returns:
itself

mulX

public final Tuple2f mulX(float v)
Multiplies this tuple's x value with v.

Parameters:
v -
Returns:
itself

mulY

public final Tuple2f mulY(float v)
Multiplies this tuple's y value with v.

Parameters:
v -
Returns:
itself

mul

public final Tuple2f mul(float vx,
                         float vy)
Multiplies this tuple's values with vx, vy.

Parameters:
vx -
vy -
Returns:
itself

divX

public final Tuple2f divX(float v)
Divides this tuple's x value by v.

Parameters:
v -
Returns:
itself

divY

public final Tuple2f divY(float v)
Divides this tuple's y value by v.

Parameters:
v -
Returns:
itself

div

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

Parameters:
vx -
vy -
Returns:
itself

scale

public final Tuple2f scale(float factorX,
                           float factorY)
Sets the value of this tuple to the scalar multiplication of tuple t1.

Parameters:
factorX -
factorY -
Returns:
itself

asReadOnly

public Tuple2f asReadOnly()

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

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

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 TupleNf<Tuple2f>
Parameters:
tuple2 - the Object with which the comparison is made
Returns:
true or false

clone

public Tuple2f 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 Tuple2f newReadOnly(float x,
                                  float y)
Creates a new Tuple2f instance.

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

newReadOnly

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

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

newReadOnly

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

Parameters:
tuple - the Tuple2f to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

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


toPool

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

Parameters:
o -