 Okay, so I don't just talk. After being immersed into the beauty of Fresno's equation and Snasmo, we are going to continue with kind of putting together a new ray tracing problem. We know all about air-guests interactions and things like that, but we for instance don't know what the representation of a ray of light could be. So let's go with this. So a ray is basically starting somewhere and it is going somewhere. It's basically it. This is what I have written here mathematically. So this is a parametric equation. We'll talk about this in a second. So always the origin, this is where we start from. This is a direction vector. This is where the ray is going and T is the distance that it had gone. It's basically it. So if T is a large number, then the ray had traveled a lot and if T is one, then that's the distance. Now we are always going to talk about vectors of human life if we are talking about direction vector. And most vectors are normed in global illumination anyway, but I would like to state this because now this T is meaningful. If D is a human life, then T is a scalar. It's a number and it tells you the distance that it's traveling. And this notation is a bit weird for many people because this are depends on T. And if you come from the regular math courses, most of what you encounter is implicit equations. So this could be an equation of a surface, f of x and y equals 0. For instance, this is an example. This would be the implicit equation of a sphere. And this is an equation. So basically you can say that whatever x and y that satisfies this equation is going to be the point of this sphere. And this is going to be this collection of points that gives you a sphere. And parametric equations don't look like that. So with these parametric equations, you can see that the x coordinate I can dig out from a function that depends on T, the y coordinate I can dig out from a different, perhaps a different function, but it also depends on T. And I can write off this whole thing as a vector form. So I'm not talking about x, y, but probably vectors. So let's see an example. The equation of a ray is such an example that you have seen above, but we're going to play a bit more with this. And the first question is, why are we doing this? Why parametric equations instead of implicit functions? Well, you will see it's enough. When we encounter a problem, and this is going to be easy to solve with parametric equations. So this is a secret. And now let's try to compute the intersection of a ray and a sphere. So I cast a ray, and I would like to know which is the first object that I hit in the scene. And if I have a scene of spheres, then this is the kind of calculation that I need to do. So the expectations are the following. I have a sphere and the ray. And it is possible that the ray hits the sphere in two different points. Well, what is impossible, if two hit points are possible, then one hit point is also possible. This is essentially the tangent of a sphere. It is just hitting at the very side. Well, this is the rare side, but this still exists. And obviously, it is possible that the ray does not hit the sphere at all. So we have, again, listed our expectations before doing any kind of calculation. And we will see that this will make things much more beautiful. So the solution for this whole problem should be some kind of mathematical something that can give me two solutions, one solution, or maybe no solutions. If I do the intersection routine and I get whatever else, then this should be incorrect. So this is what I expect to see. There is possibility of two one or zero solutions. Well, this is the equation of a sphere. P is, the P's are going to be the points on the surface of this sphere. And the C is the center of the sphere and R is obviously the radius. This is the equation of the ray. We have to mix these two together in some way in order to get an intersection. What I'm going to do is I'm going to substitute this R of T in the place of P. So what it will give me is O plus TD minus C times O plus TD minus C. It was R squared. So this is a big multiplication between the two parenthesis. And if I do this actual multiplication, then I will see that there's going to be a term which gives me the TD times TD. So there's going to be something like T squared, D squared, here. And there's going to be another term where the O minus C is multiplied with a TD on the other side. And this happens twice because both sides. And the rest is going to be a scalar term because O minus C. I'm going to multiply with O minus C. So this is going to be a scalar. I don't see T in there. And this is already quite interesting because if we smell this equation, what does this equation smell like? Raise your hand if you have some idea of what this smells like. Yes, that's going to be correct. It's a point of moment of creation of this code degree 2. It's exactly. Exactly. So this is. But I have to smell it first. So yes, indeed. That's a quadratic equation. So I have T squared, T and the scalar term equal zero. What are the coefficients? Well, simple. And T is going to be D squared. What about the B? I mean, not the T by D gain. We apologize. The B is going to be the 2D O minus C because this is what I'm going to apply. T with and the scalar term is going to be all the rest. So this should be very simple to solve. I have as a solution that possible T1 and T2 that satisfy this equation. And now the question is, is it possible that this equation has two solutions? Someone help me out. I missed some courses at kindergarten. So I don't know anything about this. Is it possible to get two solutions for this? I can't hear anything. OK, excellent. Excellent. This is the interesting part during the lecture because the teacher asked something and no answers. And this can mean two things. One thing is that no one knows the answer. And the second is that anyone knows the answer and it's so trivial that no one wants to look like an idiot. So no one says anything. And I would imagine that maybe this is the second case. So is it possible to get two solutions for this? Yes, yes. Excellent. OK, cool. Well, it's simple. If this B squared minus 4 AC is larger than 0, then the second term under the square root is going to be a number, some real number. And therefore, this is going to be T1 is minus B plus this number, T2 is a minus B minus this number. And therefore, this is going to be two different solutions. Maybe I should be wrong. So much here in the course. Can you hear this? Can you take it off? No, not always. I could take them off. Yes, and look like an academic. OK? Well, it's one solution possible. I still cannot hear anything. Yes. Very cool. When someone tells me the same thing is equals zero. So if this term is zero, then I'm adding zero. I'm subtracting zero. This is the same thing. So T1 is very simple. And it is also possible that we have no real solution if this square root term, I mean, the term under the square root is less than zero. Excellent. So this is quite beautiful because we enlisted our expectations. And it indeed needs to look like something that can give me two one or zero solutions. And if I do the math, this is exactly what happens. So this is the beauty of the whole thing. And let's imagine that I solved this equation and I got the result that T1 is 2 and T2 is minus 2. And now, what if I told you that these T's mean distances. So I'm solving the parametric equations in a way that this T means a distance. So it means that the first intersection is two times the unit distance, therefore two in the front. There could be a solution, which is a classical case for a quadratic equation where I get the second solution that is minus something. What does it mean? Yes. I think we can dismiss that because it's behind our eyes. So we don't really care about that, do we? Precisely. Precisely. So it's possible that the race starts in the middle of the sphere and then this is indeed a perfectly normal thing to happen. That there's one intersection in front of us and there's one intersection to our backs. And obviously we don't care about it too much. And if we find a solution like this, we discard it indeed. So we're studying computer science and we're not studying politics because if we would be studying politics, we would be interested in what happens behind our backs. This is computer science. So we can discard all this information.