How to Solve for Ray-Sphere Intersection Algebraically

In summary, the conversation is about solving a ray-sphere intersection algebraically, and the problem is at the step of expanding the formula into a quadratic equation form. The correct way to expand the formula is to treat (o-c) as one term and td as the other term, and then apply the distributive and commutative property of dot product to the vectors.
  • #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:

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
  • #2
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.
 
  • #3
There isn't any trick. Just apply the distributive and commutative property of dot product to the vectors.
 

1. What is "Ray-Sphere Intersection"?

Ray-Sphere Intersection is a calculation used in computer graphics and physics to determine whether a ray (a straight line with an origin and direction) intersects with a sphere in 3D space.

2. How is "Ray-Sphere Intersection" calculated?

The calculation involves finding the closest point on the ray to the center of the sphere and then determining if that point is within the radius of the sphere. This can be done using mathematical equations such as the quadratic formula.

3. Why is "Ray-Sphere Intersection" important?

Ray-Sphere Intersection is important in computer graphics because it is used to determine which objects in a 3D scene are visible to the camera. It is also used in physics simulations to detect collisions between objects.

4. How accurate is the "Ray-Sphere Intersection" calculation?

The accuracy of the calculation depends on the precision of the variables used and the complexity of the scene. In most cases, the calculation is accurate enough for practical applications in computer graphics and physics simulations.

5. Are there any limitations to "Ray-Sphere Intersection"?

Yes, there are limitations to the calculation. One limitation is that it assumes the sphere is a perfect mathematical shape with a defined center and radius. In reality, objects may have irregular shapes or be made up of multiple spheres, which can affect the accuracy of the calculation.

Similar threads

  • Calculus and Beyond Homework Help
Replies
4
Views
296
  • Calculus and Beyond Homework Help
Replies
4
Views
485
  • Calculus and Beyond Homework Help
Replies
21
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
967
  • Calculus and Beyond Homework Help
Replies
6
Views
988
  • Calculus and Beyond Homework Help
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
755
Replies
3
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
819
Replies
2
Views
1K
Back
Top