3 ms·
i think this is incorrect, i think that's computing the z component of the initial direction vector of the ray being traced if you change the initialization of
by kragen 3y ago
i think this is incorrect, i think that's computing the z component of the initial direction vector of the ray being traced
if you change the initialization of i from sgn u to 1.2 * sgn u you will get an image with the spheres a little further apart
- Sharlin 3y agoYeah, that's something of a red herring. The actual ray-sphere intersection happens on line 50: // sphere_center = (E, F, Z) E = X - I F = Y - I // solving the ray-sphere quadratic eqn... P = U * E + V * F - W * Z // discriminant D = P * P - E * E - F * F - Z * Z + 1 // if solution (ie. intersection) exists IF D > 0 // intersect_point = ray_orig + T * ray_dir // this is the closer pt, -P + SQR D is the other T = -P - SQR D
- kragen 3y agoyeah, that was what i guessed it was doing, but i couldn't remember or rederive the ray-sphere intersection formula to be sure