Hello,

I’m trying to figure out what the intersection test in sphere.cu does in every step.

I found a different algorithm which also computes the intersection points of a line with a sphere, but works a bit different.

These first steps of the algorithm in sphere.cu are clear to me.

```
float3 L = ray.origin - center;
float3 D = ray.direction;
float b = dot(L, D);
```

But I’m not sure what the next steps do:

```
float c = dot(L, L)-radius*radius;
float disc = b*b-c;
float sdisc = sqrtf(disc);
float root1 = (-b - sdisc);
float root2 = (-b + sdisc);
```

After that, the intersection points are computed like that:

```
(O + (root1 + root11)*D)
(O + root2*D)
```

Can someone try to explain the algorithm with the help of the following image?

Thank you.