If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content
Current time:0:00Total duration:2:25

Video transcript

in the previous video we saw how to compute an intersection point I that lies in the plane of a triangle but how can we tell if the point is like this one that's inside the triangle or like this one that's outside the triangle the method our ray tracer actually uses makes use of vector algebra but a method that is essentially the same it's easy to explain if you understand weighted averages notice that as I change the weights in the average the intersection point I moves and if all the weights are positive I is inside the triangle but look what happens when one or more weights is negative I escapes from the triangle bingo if we can determine the weights needed to produce I we can simply check their signs if one or two of them is negative I is outside the triangle and otherwise I is inside but how can we determine the weights let's leave them as unknowns for the moment and we'll call them little a little B and little C every point I in the plane of big a big B and Big C can be written as a weighted average of big a big B and Big C if I pick little a little B and little C so that they add to one then I can forget about the denominator the resulting equation I equals little a times big a plus little B times big B plus little C times big C represents the following three equations one for the x-coordinate one for the y-coordinate and one for the Z we know I big a big B and big C so the only unknowns are little a little B and little C so this is three equations and three unknowns that can be solved for the values of little a little B and little C once you know little a little B and little C check their signs to determine if I is inside the triangle in this final exercise you'll be asked to compute intersection points aye and determine if they lie inside or outside the triangle now after all that go forth and write your own rate racer