net.sf.j3d.threeD.raytracer.engine
Class Ray

java.lang.Object
  extended by net.sf.j3d.threeD.raytracer.engine.Ray
All Implemented Interfaces:
Cloneable

public class Ray
extends Object
implements Cloneable

A Ray object represents a 3d ray. It stores the origin and direction of a 3d ray, which are vector quantities, as Vector objects.

Author:
Mike Murray

Constructor Summary
Ray()
          Constructs a Ray object with origin and direction at the origin.
Ray(Vector origin, Vector direction)
          Constructs a Ray object using the specified origin and direction vectors.
 
Method Summary
 Object clone()
           
 double dDotd()
           
 double[] getCoords()
           
 Vector getDirection()
           
 Vector getOrigin()
           
 double oDotd()
           
 double oDoto()
           
 Vector pointAt(double t)
           
 void setDirection(Vector direction)
          Sets the direction of this Ray object to the specified direction vector.
 void setOrigin(Vector origin)
          Sets the origin of this Ray object to the specified origin vector.
 String toString()
           
 double[] transform(TransformMatrix tm)
          Transforms the origin and direction of this ray using the specified TransformMatrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ray

public Ray()
Constructs a Ray object with origin and direction at the origin.


Ray

public Ray(Vector origin,
           Vector direction)
Constructs a Ray object using the specified origin and direction vectors.

Method Detail

setOrigin

public void setOrigin(Vector origin)
Sets the origin of this Ray object to the specified origin vector.


setDirection

public void setDirection(Vector direction)
Sets the direction of this Ray object to the specified direction vector.


transform

public double[] transform(TransformMatrix tm)
Transforms the origin and direction of this ray using the specified TransformMatrix.

Parameters:
tm - TransformMatrix to use.
Returns:
{{ox, oy, oz}, {dx, dy, dz}} after transformation.

getCoords

public double[] getCoords()

oDoto

public double oDoto()
Returns:
The dot product of the origin of this ray with itself.

dDotd

public double dDotd()
Returns:
The dot product of the direction of this ray with itself.

oDotd

public double oDotd()
Returns:
The dot product of the origin of this ray with the direction of this ray.

getOrigin

public Vector getOrigin()
Returns:
The origin of this Ray object as a Vector object.

getDirection

public Vector getDirection()
Returns:
The direction of this Ray object as a Vector object.

pointAt

public Vector pointAt(double t)
Returns:
The point on the ray represented by this Ray object at distance t from the origin as a Vector object.

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object
Returns:
A String representation of this Ray object.