721
edits
Line 54: | Line 54: | ||
* sum up our points: | * sum up our points: | ||
<code> | <code> | ||
p0 + p1 + p2 + p3 ... = sum | p0 + p1 + p2 + p3 ... = sum | ||
</code> | </code> | ||
* divide the sum by out number of point: | * divide the sum by out number of point: | ||
<code> | <code> | ||
centroid = sum / num_of_points | centroid = sum / num_of_points | ||
</code> | </code> | ||
Line 67: | Line 67: | ||
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. | ||
<code> | <code> | ||
p0 = (1,1), p1= (4,2) | p0 = (1,1), p1= (4,2) | ||
c = p0 + p1; | c = p0 + p1; | ||
c = (1,1) + (4,2) = (5,3) | c = (1,1) + (4,2) = (5,3) | ||
</code> | </code> | ||
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: | ||
<code> | <code> | ||
centroid = p2 /3 = (5,3) / 2 = (2.5,1.5) | centroid = p2 /3 = (5,3) / 2 = (2.5,1.5) | ||
</code> | </code> | ||
Line 96: | Line 96: | ||
Here are the points to calculate the centroid for: | Here are the points to calculate the centroid for: | ||
<code> | <code> | ||
Point2D p0(0,0); | Point2D p0(0,0); | ||
Point2D p1(0,1); | Point2D p1(0,1); | ||
Point2D p2(1,0); | Point2D p2(1,0); | ||
Point2D p3(1,1); | Point2D p3(1,1); | ||
</code> | </code> | ||
And here is a code template to start coding from: https://repl.it/@abnutzer/Homework-2 | And here is a code template to start coding from: https://repl.it/@abnutzer/Homework-2 | ||
Press the "fork" button to work on your own copy of the code! | Press the "fork" button to work on your own copy of the code! | ||
Later in the class, our points will not be two dimensional anymore, but contain different features of our sounds. E.g. it could be 3D: A dimension for the loudness of the bass, one for the mids and one for the treble. In general the resolution of the spectral data will be much higher and thus a point of 128 dimensions or more can be considered. | Later in the class, our points will not be two dimensional anymore, but contain different features of our sounds. E.g. it could be 3D: A dimension for the loudness of the bass, one for the mids and one for the treble. In general the resolution of the spectral data will be much higher and thus a point of 128 dimensions or more can be considered. |