org.openmali.vecmath2
Class Tuple3f

java.lang.Object
  extended by org.openmali.vecmath2.TupleNf<Tuple3f>
      extended by org.openmali.vecmath2.Tuple3f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, TupleInterface<Tuple3f>
Direct Known Subclasses:
AxisAngle3f, Point3f, Vector3f

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

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

See Also:
Serialized Form

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

Tuple3f

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

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

Tuple3f

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

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

Tuple3f

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

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

Tuple3f

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

Parameters:
readOnly -

Tuple3f

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

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

Tuple3f

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

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

Tuple3f

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

Parameters:
that - the Tuple3f to copy the values from

Tuple3f

public Tuple3f()
Creates a new Tuple3f instance.

Method Detail

set

public final Tuple3f set(float x,
                         float y,
                         float 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 Tuple3f setX(float x)
Sets the value of the x-element of this tuple.

Parameters:
x -
Returns:
itself

setY

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

Parameters:
y -
Returns:
itself

setZ

public final Tuple3f setZ(float z)
Sets the value of the z-element of this tuple.

Parameters:
z -
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.

getZ

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

x

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

Parameters:
x -
Returns:
itself

y

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

Parameters:
y -
Returns:
itself

z

public final Tuple3f z(float z)
Sets the value of the z-element of this tuple.

Parameters:
z -
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.

z

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

addX

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

Parameters:
v -
Returns:
itself

addY

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

Parameters:
v -
Returns:
itself

addZ

public final Tuple3f addZ(float v)
Adds v to this tuple's z value.

Parameters:
v -
Returns:
itself

add

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

Parameters:
x -
y -
z -
Returns:
itself

subX

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

Parameters:
v -
Returns:
itself

subY

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

Parameters:
v -
Returns:
itself

subZ

public final Tuple3f subZ(float v)
Subtracts v from this tuple's z value.

Parameters:
v -
Returns:
itself

sub

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

Parameters:
x -
y -
z -
Returns:
itself

mulX

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

Parameters:
v -
Returns:
itself

mulY

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

Parameters:
v -
Returns:
itself

mulZ

public final Tuple3f mulZ(float v)
Multiplies this tuple's z value with v.

Parameters:
v -
Returns:
itself

mul

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

Parameters:
vx -
vy -
vz -
Returns:
itself

divX

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

Parameters:
v -
Returns:
itself

divY

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

Parameters:
v -
Returns:
itself

divZ

public final Tuple3f divZ(float v)
Divides this tuple's z value by v.

Parameters:
v -
Returns:
itself

div

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

Parameters:
vx -
vy -
vz -
Returns:
itself

scale

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

Parameters:
factorX -
factorY -
factorZ -
Returns:
itself

asReadOnly

public Tuple3f asReadOnly()

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

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

equals

public boolean equals(java.lang.Object o)
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 Tuple3f.

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

clone

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

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

newReadOnly

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

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

newReadOnly

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

Parameters:
tuple - the Tuple3f to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

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


toPool

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

Parameters:
o -