org.openmali.vecmath2
Class Point3d

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

public class Point3d
extends Tuple3d
implements java.io.Externalizable

A simple 3-dimensional double-Point implementation. Inspired by Kenji Hiranabe's Point3d implementation

See Also:
Serialized Form

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

Field Detail

ZERO

public static final Point3d ZERO
Constructor Detail

Point3d

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

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

Point3d

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

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

Point3d

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

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

Point3d

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

Parameters:
readOnly -

Point3d

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

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

Point3d

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

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

Point3d

public Point3d(Tuple3d tuple)
Creates a new Point3d instance.

Parameters:
tuple - the Tuple3d to copy the values from

Point3d

public Point3d()
Creates a new Point3d instance.

Method Detail

distanceSquared

public final double distanceSquared(Point3d that)


distance

public final double distance(Point3d that)


distanceSquared

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

distance

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

distanceToOriginSquared

public final double distanceToOriginSquared()


distanceToOrigin

public double distanceToOrigin()


asReadOnly

public Point3d asReadOnly()

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

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

newReadOnly

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

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

newReadOnly

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

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

newReadOnly

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

Parameters:
tuple - the Tuple3d to copy the values from

newReadOnly

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


fromPool

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


fromPool

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


fromPool

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


toPool

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

Parameters:
o -