/** * Ray stores a ray origin point and direction vector. * * @author Anthony Steed * @version 1.0 */ public class Ray { /** * Holds the ray origin */ public Point Origin; /** * Holds the ray direction */ public Vector Direction; /** * Create a default ray */ Ray() { Origin = new Point(); Direction = new Vector(0.0, 0.0, 1.0); } /** * Create a ray by copying an existing ray */ Ray(Ray r) { Origin = new Point(r.Origin); Direction = new Vector(r.Direction); } /** * Create a ray from a point and a direction. * * Values are referenced not copied * @param p the point to reference * @param v the vector to reference */ Ray(Point p, Vector v) { Origin = p; Direction = v; } /** * Get a point along a ray. * * The return point is given by Origin + (t.Direction). * @param t the distance along the ray of the point * @return a the point on the ray as specified. */ public Point getPointAt(double t) { return new Point(Origin.X + t*Direction.X, Origin.Y + t*Direction.Y, Origin.Z + t*Direction.Z); } }