You are viewing the course site for a past offering of this course. The current offering may be found here.
Lecture 9: Raytracing (23)
chenwnicole

To recap what the bottom right box is showing: if t is 0, we don't hit the circle. if t is 1, we hit it once, if t is 2, we hit it twice. all captured by the three respective images inside the box!

jgforsberg

@chenwnicole. When you say t is 0, do you mean that there are not real solutions for t and not t = 0? Because the ray does not intersect the sphere if the quadratic formula gives 2 imaginary roots. Similarly, if we get one real and one imaginary root, we get only one intersection. When both roots are real, we get two intersections.

Carpetfizz

Instead (pc)2(p - c)^2, should it say (pc)T(pc)(p-c)^T (p-c) ?

killawhale2

@Carpetfizz that is technically the correct notation, although once you work out the inner product, the result is the same.

killawhale2

@jgforsberg I believe what @chenwnicole is referring to is the value of the determinant of the quadratic equation, not the actual value of t. In this case, when the determinant is less than 0, there are no real roots, when it is zero, there is exactly one real root, and when it is positive, there are two distinct real roots.

jsc723

It seems like testing if a ray intersects with a sphere is easier then testing if it intersects with a triangle?

letrangg

this is exactly the steps we would go through to solve for a quadratic equation that we learned somewhere in middle school or high school:

https://en.wikipedia.org/wiki/Quadratic_equation

in which b^2 - 4ac is the value delta of the quadratic equation.

So in this case, as the ray always intersect with the sphere at two points, which means there are two solutions to the equation at^2 + bt + c = 0; thus resulting in t = -+b * sqrt(delta)/2a

MingweiSamuel

a small optimization: a = d*d is always 1 if d is a unit vector, so you can ignore a in the formula.

amandaawan

When thinking about how to solve for t in a particular program, I began thinking about how it would calculate and store the (possibly many) values of t (such as how MATLAB would give you multiple answers when asked. Then I remembered that we'll be working in C++ and that we can simply use the discriminant to check whether real solutions exist first before solving for t directly. In addition, given two solutions of t, we always want to choose the smallest value since we want to find the nearest intersection.

jchen12197

I agree with @jgforsberg and think @chenwnicole is referring to the number of real t there are. If there are no real t, there is no intersection. If both t are real and equal, there's exactly one intersection. If the two t are real and different values, there are two intersections. How come when we have two real ts when doing the project, we always chose the smaller t?

DavidVakshlyak

@jchen12197 I think its because we are interested in the intersection that is closet to the origin of the ray.

michellebrier

I agree with the above points -- when discriminant < 0, there'e no intersection, etc. @jchen12197, I think we choose the smaller t in the project because it represents a point closer to the ray's origin than the other t, so light should hit at the smaller t first.

Another thing I found notable from the project is that we disregard cases where both solutions (i.e., both t1 and t2) are negative, in addition to disregarding the obvious case of no intersection, as this means both points are behind the point of origin of the ray, therefore the ray can't intersect the sphere.

killawhale2

in the lecture, it was mentioned that we are looking for positive real roots, which sums up the above points

You must be enrolled in the course to comment