Current time:0:00Total duration:3:57

# 1. Weighted average of two points

## Video transcript

- So far our discussion has been largely visual and geometric and that's good because that's how our artists think. But at Pixar we also have to create computer programs and computers think best in terms of numbers, equations, and algebra. So somehow we have to bridge these two worlds. The worlds of images and geometry and the world of algebra, numbers, and equations. In fact, this bridge between these two worlds was one of the things that really drew me into computer graphics in the first place. I find it really fascinating, how the algebra and the geometry conspire to create beautiful art. So what we're going to do is develop a formula that will allow us to compute points exactly on the parabola. And that formula will allow us to write computer programs like this one, that will be able to draw the parabola without ever having to draw any of the string art lines. Our first step in the search of that formula is to generalize the idea of averaging or midpoints to the idea of weighted averages. So, let's look at our line segment AB again but instead of wanting to compute the midpoint suppose I want to compute a point M, say right about here, that weights B twice as heavily as A. There isn't anything particularly special about weighting B twice as heavily as A it's just a simple non-midpoint example. So, the algebra would say that M is one copy of A plus two copies of B and then I have to divide by three for this to be a proper average. And I can write that a little bit simpler as A plus two B over three. And one final form is 1/3 A, 'cause there's an implicit one here in front of the A and there's a 2/3 in front of the B, so 2/3 B. And notice that this 1/3 plus this 2/3 add to one. And that's another way of saying that this is a proper average. So that's the algebra, let's take a look at the geometry. Well, the geometry says that this length here, AM is going to be in proportion 2/3 to this length here, MB which is going to be in proportion 1/3. Now, notice that the algebra says that the 2/3 sticks to the B, but the geometry says that the 2/3 is opposite the B. And that looks a little bit strange at first but if you think about it, it kind of makes sense because if there was a big weight in front of B you'd expect this point to be very close to B. Okay, well we can generalize this even further and let me replace a 2/3 here with an arbitrary fraction, call it t. So the t is going to stick to the B in the algebra and now for this to be a proper average I need to put something in front of A so that something plus t is equal to one. Well, something that when added to t is one is a fraction one minus t. So my expression now is 1 minus t times A plus t times B. That's the algebra of this generalized situation. The geometry is that this 2/3 gets replaced with a t and this 1/3 gets replaced with a one minus t. So let's get some feeling for this idea by using this interactive. So here I've got a line segment that I can drag around and you can see the coordinates of A and the coordinates of B and right now it's initialized so that the point I'm computing is at the midpoint. So I would have halves in front of each A and B. But now I can slide this point around anywhere I like along this line and that corresponds to just changing the value of t. So different values of t give me different positions along the line. In the next couple of exercises you'll have an opportunity to get some experience with the idea of weighted averages. (arrow flies and hits target)