Main content

## Mathematics of rendering

Current time:0:00Total duration:2:42

# 3. Calculate intersection point

## Video transcript

- Now that you have a feel for how t works, we're ready to calculate our intersection point I between our ray CP and our line segment AB. Recall from the previous video that the slope intercept form of the line AB is y equals negative three x plus 11 and the parametric representation of the ray CP is the function R of t equals one minus t times C plus t times P. Different values of the parameter t locate different points on the ray. The intersection point that we're after is one such point on the ray so there must be some value of t, call it t star, such that I equals R of t star. This is really two equations, one for the x-coordinate of I and one for the y-coordinate. These two equations are I sub x equals R sub x of t star, which equals one minus t star times C sub x plus t star times P sub x. In the same way I sub y equals R sub y of t star, which equals one minus t star times C sub y plus t star times P sub y. In this particular case C, our camera position, has coordinates zero, zero and P has coordinates two, 1/2. So we have I sub x equals t star times two and I sub y equals t star times 1/2. I is also on the line segment AB meaning that I satisfies the slope intercept form for AB, that is I sub y equals negative three times I sub x plus 11. So we have three equations and three unknowns, I sub x, I sub y and t star. We can solve the system of equations by substituting the first two equations into the third to get an equation just in t star. 1/2 t star equals negative three times two times t star plus 11. Solve this for t star, then plug that value of t star into the first two equations to get I sub x and I sub y. And that's how it's done. Before we continue get some experience using this kind of parametric function in the next exercise.