721
edits
No edit summary |
|||
Line 59: | Line 59: | ||
Note: We sum up points simply by adding up their x and y values. E.g. | Note: We sum up points simply by adding up their x and y values. E.g. | ||
p0 = (1, | p0 = (1,1), p1= (4,2) | ||
p0 + p1 = p2; | p0 + p1 = p2; | ||
(1,2) + (2 | (1,2) + (4,2) = (5,4) | ||
Dividing the point by a number, means to divide both dimensions by the same number: | Dividing the point by a number, means to divide both dimensions by the same number: | ||
centroid = p2 /3 = ( | centroid = p2 /3 = (5,4) / 2 = (2.5,2) | ||
In this case our centroid is ( | In this case our centroid is (2.5,2). If you drew our two points and the centroid on paper, you would notice, that the centroid lies exactly in the middle of our two points. | ||
Programming Task | Programming Task |