## Homework 1, due Wednesday, Feb 3

**
Send your answer by email to the grader.
Also, please note that
I'm asking for something slightly different than
what I specified in class.
**
Write a ray/sphere intersection routine which has the following interface:

int raySphere(double ray[6], double sphere[4], double t[2]);

Your routine should take as arguments:
- An array ray[6] which specifies
*
v*_{x},
v_{y},
v_{z},
w_{x},
w_{y},
w_{z}
- An array sphere[4] which specifies
*
c*_{x},
c_{y},
c_{z},
R
- An array t[2]
in which to place the values for
*t* of any intersections.
If there are two intersections, make sure that
t[0] < t[1].

Your routine should return a number between zero and two,
indicating the number of times the ray intersects the sphere.
Remember that you need to convert the equation:

*
(w*_{x}t + (v_{x}-c_{x}))^{2} +
(w_{y}t + (v_{y}-c_{y}))^{2} +
(w_{z}t + (v_{z}-c_{z}))^{2} - R^{2} = 0

into something of the form **A**t^{2} + **B**t + **C** = 0,
just as we did in class,
and then solve using the quadratic equation
*
t = (-***B** ± sqrt(**B**^{2} - 4**AC**)) / 2**A**
to get the two values of *t*.
If the value under the square root is negative,
that means the ray has missed the sphere, in which case your routine should
return a value of zero.