nature-of-code / The-Nature-of-Code-archive

The very first build system for The Nature of Code
http://natureofcode.com
913 stars 151 forks source link

Unnecessary step in Example 6.7 #323

Closed RectangleWorld closed 10 years ago

RectangleWorld commented 11 years ago

Just started reading this book online and it's great! I'll be ordering a print version ASAP.

In example 6.7, there seems to be one unnecessary step (unless I'm missing something):

sum.div(count);
sum.normalize();

Since the vector is being normalized anyway, first dividing by count will have no effect.

shiffman commented 10 years ago

Ok, I simplified the examples and added a sentence: "(In fact, we don't have to divide by count anymore since we are manually setting the magnitude.)" I also changed the code to use setMag()