How to Solve for Ray-Sphere Intersection Algebraically

  • Thread starter Thread starter Bucky
  • Start date Start date
  • Tags Tags
    Intersection
Bucky
Messages
79
Reaction score
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:

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:
Physics news on Phys.org
You're expanding it out too far. The idea is to get it in a quadratic form. You treated it as three terms being squared and they treated it as two terms. Treat (o-c) as one term in the initial brackets and td as the other term. Then expand keeping (o-c) together as one term.
 
There isn't any trick. Just apply the distributive and commutative property of dot product to the vectors.
 
Prove $$\int\limits_0^{\sqrt2/4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx = \frac{\pi^2}{8}.$$ Let $$I = \int\limits_0^{\sqrt 2 / 4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx. \tag{1}$$ The representation integral of ##\arcsin## is $$\arcsin u = \int\limits_{0}^{1} \frac{\mathrm dt}{\sqrt{1-t^2}}, \qquad 0 \leqslant u \leqslant 1.$$ Plugging identity above into ##(1)## with ##u...
Back
Top