Designing a Ray Tracer
Building a ray tracer is simple. First we start with a convenient vector algebra library.
class Vector3D {
public float x, y, z;
// constructors
public Vector3D( ) { }
public Vector3D(float x, float y, float z);
public Vector3D(Vector3D v);
// methods
public float dot(Vector3D B); // this with B
public float dot(float Bx, float By, float Bz); // B spelled out
public static float dot(Vector3D A, Vector3D B); // A dot B
public Vector3D cross(Vector3D B); // this with B
public Vector3D cross(float Bx, float By, float Bz); // B spelled out
public static Vector3D cross(Vector3D A, Vector3D B); // A cross B
public float length( ); // of this
public static float length(Vector3D A); // of A
public void normalize( ); // makes this unit length
public static Vector3D normalize(Vector3D A); // makes A unit length
public String toString(); // convert to a string
}
|