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.

## Pixar in a Box

### Course: Pixar in a Box>Unit 3

Lesson 2: Mathematics of subdivision

# Weighted average of three points

First we'll review weighted averages of two points and extend the idea to three points.
Practice weighted averages of two points in Environment Modeling if you haven't seen it before.

## Want to join the conversation?

• I don't understand why:
``M is the weighted average of three points, A, B and C. What is the position of M of using weights of 0, 0 and 0, respectively?``
results in "M is undefined" rather than M defaulting to the center of △ABC triangle (which is the case for all other situations where the values are equal, like: 1, 1, 1, or 5,5,5 etc.). If there is no weight, it should be in the center of the triangle, right? • At he says that to make the expression a proper average you have to divide by a+b. Why? By doing that you change the value don't you? • When you're taking an average of several numbers, you add all the numbers up, then divide by the number of numbers. So the average of the set [1,7,3] is (1 + 7 + 3) / 3.

When you're taking a weighted average, you count one of your numbers more than once. So if you weight the previous average so that the 3 is twice as important as the other two is (1 + 7 + 3 + 3) / 4.

In the same way, when you take the weighted average of geometric points, if you increase a point's importance, you have to increase the divisor equal to the extra level of importance you give it.

To illustrate: If you're simply averaging two points A and B, then the formula is (A + B) / 2. The divisor is equal to the number of points you're averaging. If you want A to count twice as much as B, then it's (A + A + B) / 3. Again, the divisor is equal to the number of points, even though one of them is really the same point twice. Here, the "little a" is 2 and the "little b" is 1. So it could be rewritten as (2*A + 1*B) / 2 + 1.

If you don't increase the divisor like this, you won't get an average, and your new point will wind up in the wrong place.

• - 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. • what is weighted average? • Imagine that you want the average of two points, X and Y, but you want Y to be twice as important. So rather than saying (X + Y)/2, you average X, Y, and Y, saying (X + 2Y)/3.

Now, the technical definition: The weighted average of vectors (fancy word for points) X_1, X_2, X_3, . . ., X_n with weights A_1, A_2, A_3, . . ., A_n is (A_1 X_1 + A_2 X_2 + A_3 X_3 + . . . + A_n X_n)/(A_1 + A_2 + A_3 + . . . + A_n).
• I forgot!! In one video, they had a recommended free software or something, and I wanted to try that out! It may be past this point..if anyone finds it, can you tell me which video? Thanks! • I didn't understand what he said at the end. (The language he was speaking).
Also, what did he say? • Hi I am kinda new to this, so what does little a, little b and little c represent? • How is M the weighted average of A, B and C   