- #1
Bucky
- 82
- 0
I'm trying to work through an explanation of how a ray-sphere intersection can be solved algebraically from here:
http://wiki.cgsociety.org/index.php/Ray_Sphere_Intersection
My problem is at this step:
I don't understand how they've expanded the formula.
I thought you just multiplied each term in the left bracket by each term in the right bracket...which gave me...
(o.o) + (c.c) - 2(c.o) - 2(d.c) + 2t(d.o) + t^2 (d.d) = r^2
Have I made a mistake or is there some trick I'm missing?
http://wiki.cgsociety.org/index.php/Ray_Sphere_Intersection
My problem is at this step:
we can find the t at which the ray intersects the sphere by setting ray(t) equal to p
(o + t d - c) . (o + t d - c) = r^2
To solve for t we first expand the above into a more recognisable quadratic equation form
(d.d)t^2 + 2 (o - c) . dt + (o - c) - r^2 = 0
I don't understand how they've expanded the formula.
I thought you just multiplied each term in the left bracket by each term in the right bracket...which gave me...
(o.o) + (c.c) - 2(c.o) - 2(d.c) + 2t(d.o) + t^2 (d.d) = r^2
Have I made a mistake or is there some trick I'm missing?
Last edited by a moderator: