org.openmali.vecmath2
Class Ray3f

java.lang.Object
  extended by org.openmali.vecmath2.Ray3f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Ray3f
extends java.lang.Object
implements java.io.Externalizable

Simple three-dimensional ray implementation.

See Also:
Serialized Form

Constructor Summary
  Ray3f()
          Creates a new Ray3f.
protected Ray3f(boolean readOnly)
          Creates a new Ray3f.
protected Ray3f(boolean readOnly, float origX, float origY, float origZ, float direcX, float direcY, float direcZ)
          Creates a new Ray3f.
protected Ray3f(boolean readOnly, Point3f origin, Vector3f direction)
          Creates a new Ray3f.
protected Ray3f(boolean readOnly, Ray3f template)
          Clone constructor.
  Ray3f(float origX, float origY, float origZ, float direcX, float direcY, float direcZ)
          Creates a new Ray3f.
  Ray3f(Point3f origin, Vector3f direction)
          Creates a new Ray3f.
  Ray3f(Ray3f template)
          Clone constructor.
 
Method Summary
 Ray3f clone()
          Creates a clone.
 int deserialize(int pos, byte[] buffer)
          Deserializes this instanc'es data from the byte array.
 boolean equals(java.lang.Object o)
          
 boolean equals(Ray3f ray)
          Checks if the given ray equals this one.
static Ray3f fromPool()
          Allocates an Ray3f instance from the pool.
static Ray3f fromPool(float ox, float oy, float oz, float dx, float dy, float dz)
          Allocates an Ray3f instance from the pool.
static Ray3f fromPool(Ray3f ray)
          Allocates an Ray3f instance from the pool.
static Ray3f fromPool(Tuple3f origin, Vector3f direction)
          Allocates an Ray3f instance from the pool.
 Vector3f getDirection()
           
 float getLength()
           
 float getLengthSquared()
           
 Point3f getOrigin()
           
protected  int getSerializationBufferSize()
           
 boolean isDirty()
           
 boolean isReadOnly()
           
 float length()
           
 float lengthSquared()
           
static Ray3f newReadOnly()
          Creates a new Ray3f.
static Ray3f newReadOnly(float origX, float origY, float origZ, float direcX, float direcY, float direcZ)
          Creates a new Ray3f.
static Ray3f newReadOnly(Point3f origin, Vector3f direction)
          Creates a new Ray3f.
static Ray3f newReadOnly(Ray3f template)
          Clone constructor.
 void readExternal(java.io.ObjectInput in)
           
 int serialize(int pos, byte[] buffer)
          Serializes this instanc'es data into the byte array.
 Ray3f set(float ox, float oy, float oz, float dx, float dy, float dz)
          Sets this ray to the passed parameters.
 Ray3f set(Ray3f ray)
          Sets this ray to be equal to the passed one.
 Ray3f set(Tuple3f origin, Vector3f direction)
          Sets this ray to the passed parameters.
 boolean setClean()
          Marks this ray non-dirty.
 Ray3f setDirection(float x, float y, float z)
          Sets the ray's direction.
 Ray3f setDirection(Tuple3f direction)
          Sets the ray's direction.
 Ray3f setOrigin(float x, float y, float z)
          Sets the ray's origin.
 Ray3f setOrigin(Tuple3f origin)
          Sets the ray's origin.
 void setZero()
          Sets origin and direction to zero.
static void toPool(Ray3f o)
          Stores the given Ray3f instance in the pool.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ray3f

protected Ray3f(boolean readOnly,
                float origX,
                float origY,
                float origZ,
                float direcX,
                float direcY,
                float direcZ)
Creates a new Ray3f.

Parameters:
readOnly -
origX -
origY -
origZ -
direcX -
direcY -
direcZ -

Ray3f

protected Ray3f(boolean readOnly,
                Point3f origin,
                Vector3f direction)
Creates a new Ray3f.

Parameters:
readOnly -
origin - the new origin point
direction - the new direction vector

Ray3f

protected Ray3f(boolean readOnly)
Creates a new Ray3f.

Parameters:
readOnly -

Ray3f

protected Ray3f(boolean readOnly,
                Ray3f template)
Clone constructor.

Parameters:
readOnly -
template -

Ray3f

public Ray3f(float origX,
             float origY,
             float origZ,
             float direcX,
             float direcY,
             float direcZ)
Creates a new Ray3f.

Parameters:
origX -
origY -
origZ -
direcX -
direcY -
direcZ -

Ray3f

public Ray3f(Point3f origin,
             Vector3f direction)
Creates a new Ray3f.

Parameters:
origin - the new origin point
direction - the new direction vector

Ray3f

public Ray3f()
Creates a new Ray3f.


Ray3f

public Ray3f(Ray3f template)
Clone constructor.

Parameters:
template -
Method Detail

isReadOnly

public final boolean isReadOnly()
Returns:
Is this ray a read-only one?

setClean

public final boolean setClean()
Marks this ray non-dirty. Any value-manipulation will mark it dirty again.

Returns:
the old value

isDirty

public final boolean isDirty()
Returns:
This ray's dirty-flag

setZero

public final void setZero()
Sets origin and direction to zero.


setOrigin

public final Ray3f setOrigin(float x,
                             float y,
                             float z)
Sets the ray's origin.

Parameters:
x -
y -
z -
Returns:
itself

setOrigin

public final Ray3f setOrigin(Tuple3f origin)
Sets the ray's origin.

Parameters:
origin - new origin
Returns:
itself

getOrigin

public final Point3f getOrigin()
Returns:
the ray's origin

setDirection

public final Ray3f setDirection(float x,
                                float y,
                                float z)
Sets the ray's direction.

Parameters:
x -
y -
z -
Returns:
itself

setDirection

public final Ray3f setDirection(Tuple3f direction)
Sets the ray's direction.

Parameters:
direction - new direction
Returns:
itself

getDirection

public final Vector3f getDirection()
Returns:
the ray's direction

getLengthSquared

public final float getLengthSquared()
Returns:
the ray's length same as lengthSquared()

lengthSquared

public final float lengthSquared()
Returns:
the ray's length same as getLengthSquared()

getLength

public final float getLength()
Returns:
the ray's length same as length()

length

public final float length()
Returns:
the ray's length same as getLength()

clone

public Ray3f clone()
Creates a clone.

Overrides:
clone in class java.lang.Object

set

public final Ray3f set(float ox,
                       float oy,
                       float oz,
                       float dx,
                       float dy,
                       float dz)
Sets this ray to the passed parameters.

Parameters:
ox - the new origin point's x-coordinate
oy - the new origin point's y-coordinate
oz - the new origin point's z-coordinate
dx - the new direction vector's x-coordinate
dy - the new direction vector's y-coordinate
dz - the new direction vector's z-coordinate
Returns:
itself

set

public final Ray3f set(Tuple3f origin,
                       Vector3f direction)
Sets this ray to the passed parameters.

Parameters:
origin - the new origin point
direction - the new direction vector
Returns:
itself

set

public final Ray3f set(Ray3f ray)
Sets this ray to be equal to the passed one.

Returns:
itself

equals

public boolean equals(Ray3f ray)
Checks if the given ray equals this one.

Parameters:
ray - the ray to test for equality

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this ray

serialize

public int serialize(int pos,
                     byte[] buffer)
Serializes this instanc'es data into the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

deserialize

public int deserialize(int pos,
                       byte[] buffer)
Deserializes this instanc'es data from the byte array.

Parameters:
pos -
buffer -
Returns:
the incremented position

getSerializationBufferSize

protected int getSerializationBufferSize()
Returns:
the necessary size for a serialization byte array.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

newReadOnly

public static Ray3f newReadOnly(float origX,
                                float origY,
                                float origZ,
                                float direcX,
                                float direcY,
                                float direcZ)
Creates a new Ray3f.

Parameters:
origX -
origY -
origZ -
direcX -
direcY -
direcZ -

newReadOnly

public static Ray3f newReadOnly(Point3f origin,
                                Vector3f direction)
Creates a new Ray3f.

Parameters:
origin - the new origin point
direction - the new direction vector

newReadOnly

public static Ray3f newReadOnly()
Creates a new Ray3f.


newReadOnly

public static Ray3f newReadOnly(Ray3f template)
Clone constructor.

Parameters:
template -

fromPool

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


fromPool

public static Ray3f fromPool(float ox,
                             float oy,
                             float oz,
                             float dx,
                             float dy,
                             float dz)
Allocates an Ray3f instance from the pool.


fromPool

public static Ray3f fromPool(Tuple3f origin,
                             Vector3f direction)
Allocates an Ray3f instance from the pool.


fromPool

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


toPool

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

Parameters:
o -