Homework 1

When you have finished the assignment below, email it to me at perlin@nyu.edu. Next week we'll set up a different system for handing in homework, but right now I want to gather your email addresses. Also, please also include in that email the URL of your student web page. You'll be using that web page to show your homework for this class.

Also, try to read through Chapter 5 in the textbook before next class. In the next lecture we'll be going over the material in that chapter.


Given a sphere defined by its center C = [cx,cy,cz] and its radius r, as well as a viewing ray (E + tW) defined by its origin E = [ex,ey,ez] and its view direction W = [wx,wy,wz], where t is greater than zero:
  1. Find out whether the ray hits the sphere, and if so, how far along the ray is the intersection. In other words, find the value of parameter t in terms of E,W,C, and r. Demonstrate your solution by implementing the following procedure in Java or in C:
       int raySphere(double E[], double W[], double C[], double r, double T[])
    
    which computes the intersection of a ray with a sphere. raySphere should return the number of intersections of the ray with the sphere, and place the value of each intersection parameter (if any) in array T. For example, if there are two intersections then raySphere should place values into T[0] and T[1], and return the value 2. Remember to disregard any non-positive values of t.

  2. Implement the following procedure in Java or in C:
       void rayPoint(double E[], double W[], double t, double P[])
    
    which calculates a point P along a ray, given parameter t.