org.openmali.vecmath2
Class Point3f

java.lang.Object
  extended by org.openmali.vecmath2.TupleNf<Tuple3f>
      extended by org.openmali.vecmath2.Tuple3f
          extended by org.openmali.vecmath2.Point3f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, PointInterface<Tuple3f,Point3f>, TupleInterface<Tuple3f>

public class Point3f
extends Tuple3f
implements java.io.Externalizable, PointInterface<Tuple3f,Point3f>

A simple 3-dimensional float-Point implementation. Inspired by Kenji Hiranabe's Point3f implementation

See Also:
Serialized Form

Field Summary
static Point3f ZERO
           
 
Fields inherited from class org.openmali.vecmath2.TupleNf
isDirty, roTrick, values
 
Constructor Summary
  Point3f()
          Creates a new Point3f instance.
protected Point3f(boolean readOnly)
          Creates a new Point3f instance.
protected Point3f(boolean readOnly, float[] values, boolean[] isDirty, boolean copy)
          Creates a new Point3f instance.
protected Point3f(boolean readOnly, float x, float y, float z)
          Creates a new Point3f instance.
protected Point3f(boolean readOnly, Tuple3f tuple)
          Creates a new Point3f instance.
  Point3f(float[] values)
          Creates a new Point3f instance.
  Point3f(float x, float y, float z)
          Creates a new Point3f instance.
  Point3f(Tuple3f tuple)
          Creates a new Point3f instance.
 
Method Summary
 Point3f asReadOnly()
          
 Point3f clone()
          Creates and returns a copy of this object.
 float distance(float p2x, float p2y, float p2z)
           
 float distance(Point3f that)
          
 float distanceSquared(float p2x, float p2y, float p2z)
           
 float distanceSquared(Point3f that)
          
 float distanceToOrigin()
          
 float distanceToOriginSquared()
          
static Point3f fromPool()
          Allocates an Point3f instance from the pool.
static Point3f fromPool(float x, float y, float z)
          Allocates an Point3f instance from the pool.
static Point3f fromPool(Tuple3f tuple)
          Allocates an Point3f instance from the pool.
 Point3f getReadOnly()
          
static Point3f newReadOnly()
          Creates a new Point3f instance.
static Point3f newReadOnly(float[] values)
          Creates a new Point3f instance.
static Point3f newReadOnly(float x, float y, float z)
          Creates a new Point3f instance.
static Point3f newReadOnly(Tuple3f tuple)
          Creates a new Point3f instance.
static void toPool(Point3f o)
          Stores the given Point3f instance in the pool.
 
Methods inherited from class org.openmali.vecmath2.Tuple3f
add, addX, addY, addZ, 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.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
 

Field Detail

ZERO

public static final Point3f ZERO
Constructor Detail

Point3f

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

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

Point3f

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

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

Point3f

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

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

Point3f

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

Parameters:
readOnly -

Point3f

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

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

Point3f

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

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

Point3f

public Point3f(Tuple3f tuple)
Creates a new Point3f instance.

Parameters:
tuple - the Tuple3f to copy the values from

Point3f

public Point3f()
Creates a new Point3f instance.

Method Detail

distanceSquared

public final float distanceSquared(Point3f that)

Specified by:
distanceSquared in interface PointInterface<Tuple3f,Point3f>
Returns:
the squared distance betweeen this point and the other one

distance

public final float distance(Point3f that)

Specified by:
distance in interface PointInterface<Tuple3f,Point3f>
Returns:
the distance betweeen this point and the other one

distanceSquared

public final float distanceSquared(float p2x,
                                   float p2y,
                                   float p2z)

distance

public final float distance(float p2x,
                            float p2y,
                            float p2z)

distanceToOriginSquared

public final float distanceToOriginSquared()

Specified by:
distanceToOriginSquared in interface PointInterface<Tuple3f,Point3f>
Returns:
the squared distance betweeen this point and the origin

distanceToOrigin

public float distanceToOrigin()

Specified by:
distanceToOrigin in interface PointInterface<Tuple3f,Point3f>
Returns:
the distance betweeen this point and the origin

clone

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

Overrides:
clone in class Tuple3f
Returns:
a clone of this instance.
See Also:
Cloneable

asReadOnly

public Point3f asReadOnly()

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

Overrides:
getReadOnly in class 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()

newReadOnly

public static Point3f newReadOnly(float x,
                                  float y,
                                  float z)
Creates a new Point3f instance.

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

newReadOnly

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

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

newReadOnly

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

Parameters:
tuple - the Tuple3f to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

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


toPool

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

Parameters:
o -