Main content

## Pixar in a Box

### Unit 15: Lesson 2

Mathematics of rendering- Start here!
- 1. Ray tracing intuition
- 2D rendering intuition
- 2. Parametric form of a ray
- Parametric ray intuition
- 3. Calculate intersection point
- Solve for t
- 4. Using the line equation
- Ray intersection with line
- 5. 3D ray tracing part 1
- Ray intersection with plane
- 6. 3D ray tracing part 2
- Triangle intersection in 3D

© 2022 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# 4. Using the line equation

Next we need to throw away the slope-intercept form and use the line equation instead.

Click here to see why dividing by zero is bad.

Click here to try the interactive program shown in the video.

Click here to see why dividing by zero is bad.

Click here to try the interactive program shown in the video.

## Video transcript

- There's a detail that we need to attend to: there's a slight problem with the slope intercept form of the sine geometry. The problem is that if AB is vertical, the slope isn't defined. To see that, look at the slope intercept form in general: y equals m x plus i, where m is the slope and i is the y-intercept. The slope m is the change in y divided by the change in x, meaning that if AB is a vertical line, there is no change in x. So, computing the slope would mean dividing by zero, which is bad. (bell) But we can eliminate this problem by multiplying through by the change in x. So, multiplying through by the change in x, we get change in x times y equals change in y times x plus i times change in x. It's common to move everything to one side and re-write this as change in y times x minus change in x times y plus i times change of x equals zero. Call this term, change in y, a value: a; this term, negative change in x, a value: b; and this term, i times change of x, a value: c; meaning we can write an equation for the line as a x plus b y plus c equals zero. An equation like this for a line goes by several names. It is sometimes called the line equation. It's also called the implicit form for the line. Let's do an example for this specific line, AB. Change in y is negative three. Change in x is one, and i is 11. So, negative three x minus y plus 11 equals zero. That line equation is shown here. Notice that as I move A and B around, the line equation updates accordingly. The line equation can be used with the parametric form of array to compute intersection points, this time, for any type of line, even vertical ones. Use the next exercise to practice computing intersection points using line equations.