Write a ray/sphere intersection routine which has the following interface:
int raySphere(double ray, double sphere, double t);Your routine should take as arguments:
Remember that you need to convert the equation:
(wxt + (vx-cx))2 + (wyt + (vy-cy))2 + (wzt + (vz-cz))2 - R2 = 0into something of the form At2 + Bt + C = 0, just as we did in class, and then solve using the quadratic equation t = (-B ± sqrt(B2 - 4AC)) / 2A 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.