Git Product home page Git Product logo

noc-book's People

Contributors

almcd avatar alterebro avatar andersonfreitas avatar ascherer avatar beeblerox avatar chriskelley avatar danbernier avatar drguildo avatar evanemolo avatar javl avatar joeyklee avatar jschulenklopper avatar kyeshmz avatar liam-middlebrook avatar makio135 avatar mrfabbri avatar murtraja avatar namin avatar nelliemckesson avatar nocksock avatar nonas-hunter avatar origamike avatar rochaporto avatar runemadsen avatar scotthmurray avatar shannonfry avatar shiffman avatar sklise avatar swfenton avatar timsbryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

noc-book's Issues

"the the" typo

In chapter 6 there is a "the the" typo:

Complex systems often include a feedback loop where the the output of the system....

Chap 1 - Vector Subtraction - where to call translate()

Working through the Nature of Code w/ p5js. I'm using the p5 editor version 0.5.7

In the vector subtraction example (https://github.com/shiffman/The-Nature-of-Code-Examples-p5.js/blob/master/chp01_vectors/NOC_1_03_vector_subtraction/sketch.js)... if I run this code as-is, I see a line blip from the top left corner to center on frame 1, then no other lines. However, if I move the translate() call into setup(), the sketch behaves as expected.

Is this a possible issue with the p5 editor? Or has p5js syntax been updated to change the way translate() works?

Thanks!

Broken image link on figure 1.10 - Chapter 1: Vectors

On the website, the image for figure 1.10 doesn't load in Chapter 1: Vectors:

<img src="imgs/chapter01/ch01_10.png" alt="Nature of Code Image">

Based on the other image paths on the page, I think it's just missing /book/ at and start so it should be:

<img src="/book/imgs/chapter01/ch01_10.png" alt="Nature of Code Image">

Friction

First of all, I don't want to be considered as a spammer or something. I'm just trying to help. I wonder if you prefer me to create a Github Issue for each little mistake I find or you prefer me reading a lot of the book before creating one? I personally think creating one for each would be the best, since each error would be represented by an Issue. But if you don't prefer like that, I can do the other way around.

Well, what I want to talk about friction is that the way you did, it's happening all the time (you said something like that yourself). But shouldn't it happen only when the object is on a surface? That is easily checkable with an if. I'm sorry doing these questions/issues, it's just I'm really enjoying this book and I want to understand everything well and correct.

CSS class vs. data attribute?

Question for @runemadsen about https://github.com/magicbookproject/magicbook.

In the first edition of NOC, the ASCIIDOC would resolve to CSS classes, i.e.

<div class="note" id="pseudo-random-numbers-o1bcX">
<h1>Pseudo-Random Numbers</h1>
</div>

The version I have now written in HTMLBook looks like:

<div data-type="note" id="pseudo-random-numbers-o1bcX">
<h1>Pseudo-Random Numbers</h1>
</div>

My old CSS is:

.note {
  font-size: 10pt;
}

But I think it should now be:

[data-type="note"] {
  font-size: 10pt;
}

I ask b/c this question applies across the board to just about everything. Is one of these preferable? Should adjust my CSS to use data attributes? Or adjust my HTML to go back to classes?

Formatting for classes, variables, functions

In NOC 1.0, we had:

  • <span class="klass">Walker</span>
  • <span class="function">setup()</span>
  • <span class="var">x</span>

and probably more?

Right now, the conversion resulted in:

  • <strong klass="">Walker</strong>
  • <strong function="">setup()</strong>
  • <strong class="var">x</strong>

I can do a global regex search/replace, but want to confirm the correct markup.

Typing errors

Chapter 1. Vectors
Vector multiplication
More Number Properties with Vectors

I think the following sentence
The distributive rule with 2 scalars, 1 vector: (n_m)_v⃗ =n_v⃗ +m_v⃗
should be
The distributive rule with 2 scalars, 1 vector: (n+m)_v⃗ =n_v⃗ +m*v⃗

How do you think?

error in web book in section 1.4

I just want to thank you for providing this wonderful book for free and would like to note a small mistake in section 1.4 where you give an example on calculating mean and standard deviation. The value of the average variance should be 228.81 not 254.23 as mentioned. The value of the standard deviation is correct though.

Thanks
Anis Nazer

4.3 The ArrayList: plist | particles

In the section where the "enhanced for loop" is first shown, the name of the ArrayList that is created is plist, but the name of the list that is inside the loop is particles. Apparently the name plist comes from the comparison between an array and a list (parray vs plist). However, as the name that is used throughout the chapter is particles, that specific example got a mix of both names.

atan using x/y instead of y/x

In chapter 3, oscillation, why is atan being passed in x/y, shouldn't it be y/x?

V1 ⇒ angle = atan(-4/3) = atan(-1.25) = -0.9272952 radians = -53 degrees
V2 ⇒ angle = atan(4/-3) = atan(-1.25) = -0.9272952 radians = -53 degrees

Code demos still running when off-screen

First off this is a great book. I've been trying to get to grips with the physics of vectors and force for years now and this is the first presentation of the topic that has actually made sense to me.

One small request; your in-browser code examples, while helpful, eat up a lot of CPU and thus laptop battery power. They only kick off once they scroll into view, which is great, but they keep going once you've scrolled past them.

Since some of the chapters are very long I tend to wind up leaving the tab open for days at a time. Since they contain numerous running code examples this can add up to a lot of wasted cycles and quickly drained batteries unless I remember to refresh the page or manually pause each example as I go.

Could you alter the JS used to run the examples so that they pause execution when you scroll them off-screen?

1.9 Static vs. Non-Static Functions

Hi Daniel,

This is a great book. Thanks for publishing it.

I was going through the first chapter while writing my own code in Java and noticed something rather inefficient in "1.9 Static vs. Non-Static Functions".

The problem is that these static methods create new instances of PVector every time you call them, which could happen 60 time per second when you animate a moving object and a lot more frequently if you have a complex scene. These temporary objects would soon have to be discarded and there would be a lot of work for the Garbage collector.

As an alternative I would recommend using a copyFrom method similar to this:
PVector copyFrom(PVector v) {
x = v.x;
y = v.y;
return this;
}

That method can be combined with using a temporary vector that is reused over and over without having to instantiate new objects. For example:
class MyAnimation
{
PVector v;
PVector u;
PVector tmp;

public MyAnimation()
{
    v = new PVector(0,0);
    u = new PVector(4,5);
    tmp = new PVector(0,0);
}

void update()
{
    tmp.copyFrom(u);
    tmp.add(v);
    // At this point you have the sum of u and v in tmp
    // while the original two vectors remain unchanged
}

}

Hope this helps,
Vihren

figure 3.13

sin and cosine are inverted in the formula, oops

Intro-1.4: Using the Random class (Processing 3.0.1)

Online book, Introduction-1.4 mentions:

Instead, we can make use of a class known as Random, which we get for free as part of the default Java libraries imported into Processing.
To use the Random class, we must first declare a variable of type Random and create the Random object in setup().

Random generator;

void setup() {
  size(640,360);
  generator = new Random();
}

In Processing 3.0.1 this didn't work for me without importing java.util.Random to the sketch.

I know this is not part of the examples but I'm posting the issue because I think it can be a source of confusion for beginner readers using the latest version of Processing.

P.S. Thanks a lot for making the book. Can't wait for the next edition!

Misleading definition of the Normal distribution

At the beginning of "I.4 A Normal Distribution of Random Numbers", it is said:

A distribution of values that cluster around an average (referred to as the “mean”) is known as a “normal” distribution.

This is very misleading, because a distribution of values that cluster around an average is not necessarily a normal distribution. There are maaaany other distributions that are also clustered around the mean (exples: the Cauchy distribution, the Laplace distribution, the t-distribution...)
A normal distribution is one of these, yes, but a very special case and the "clustered around the mean" is by no means its definition.

Index

Did we lose all of the indexing during the conversion?

((("natural phenomena","Perlin noise and")))
((("non-uniform distributions","Perlin noise")))
((("distributions, non-uniform","Perlin noise")))
((("Perlin noise","natural phenomena, modeling with")))
((("_Tron_ (1982)")))

In conversion I sometimes see:

<a data-primary="" data-type="indexterm" em=""> </a>

But it's empty.

Math notation

I need a way to deal with math notation. The previous solution used ASCIIDOC variables. For example:

In other words: {wuplusv}
can be written as: {wxuxplusvx}
{wyuyplusvy}
Then, replacing u and v with their values from Figure 1.6, we get: {wx53}
{wy24}
which means that:
{wx8} {wy6}
Finally, we write that as a vector: {w86}

These variables held elaborate SVG markup for the print, but rendered to MathML with MathJax for HTML.

https://github.com/shiffman/The-Nature-of-Code-archive/blob/master/raw/chapters/mathsvgfiles.asc
https://github.com/shiffman/The-Nature-of-Code-archive/blob/master/raw/chapters/math.asc

page breaks

is this still valid / correct for atlas?

<div style="page-break-after:always;">&nbsp;</div>

feedback from reader

Hello Daniel,

There is a segment of code excerpted from the Introduction.

void step() {
                    //Yields any floating point number between -1.0 and 1.0
    float stepx = random(-1, 1);
    float stepy = random(-1, 1);
    x += stepx;
    y += stepy;
  }

I think it would causes some misunderstanding. According to the text, it would be easier to conclude that this segment of code has the same effect as this one :

  void step() {
    int stepx = int(random(3))-1;
    int stepy = int(random(3))-1;
    x += stepx;
    y += stepy;
  }

But the program shows that the walker using that code will go up and left, which may not be anticipated by some people.

At first, I was confused, because the probability of taking any direction is not equal. After I read the text several times, I found, actually the text does not state that segment of code would produce the same result. In fact, there is no problem of it. But, if I did not try to run the code, I would think they are no different. And maybe some others would think the same way.

So, instead of using random(-1, 1), I think it would be better to use random(-1, 2) here.

Example 1.3 not really clear

I'm checking out the book because I'd like to use it to explain Vectors to my students. However I'm pretty new to the subject, so I'm on student level as well.

I was wondering if Example 1.3. could be not more clear? You use a translate(width/2, height/2) to explain the subtraction. However that is a completely different concept (and pretty difficult as well, regarding the matrix). You need to translate, to show the subtract.

However without translate, you don't need the subtraction:

void setup() {
  size(640,360);
}

void draw() {
  background(255);
  //[full] Two PVectors, one for the mouse location and one for the center of the window
  PVector mouse  = new PVector(mouseX,mouseY);
  PVector center = new PVector(width/2,height/2);
  //[end]
  // PVector subtraction!
  //mouse.sub(center);
    // Draw a line to represent the vector.
  //translate(width/2,height/2);
  line(center.x,center.y,mouse.x,mouse.y);
}

I feel that something based on the example from the Processing reference could be more clear:

PVector v1, v2;

void setup() {
  size(200,200);
  noLoop();
  v1 = new PVector(25, 25, 0);
  v2 = new PVector(100, 100, 0); 
}

void draw() {
  ellipse(v1.x, v1.y, 12, 12);
  ellipse(v2.x, v2.y, 12, 12);
  v2.sub(v1);
  ellipse(v2.x, v2.y, 24, 24);
}

typo on page 85 & 86

In section 2.8 Air and Fluid Resistance (page 85), at the bottom of the page with the if() block, it says:

if (movers[i].isInside(liquid)) {movers[i].drag(liquid);}

But in the code example that correspond to this section, you have the function "boolean Liquid.contains(Mover m)" instead of "boolean Mover.isInside(Liquid liquid)".

Also, instead of "Mover.drag(Liquid)" like you have in the book, the code example uses "Liquid.drag(Mover m)".

Basically, the placement of Mover and Liquid classes don't match up between page 85 and the code examples, as well as a function name change. These typos carry over into page 86, where you talk about adding functions to the Mover class, functions that are written in the Liquid class in the examples.

Typo in section I.3

Not every monkey will have a equal chance of reproducing.

Which should probably be:

Not every monkey will have an equal chance of reproducing.

Possible typo in Ch1: Distributive rule for vectors

Hello! Love this book.

Just wanted to query what you've written in Chapter 1 for the distributive rule:

The distributive rule with 2 scalars, 1 vector: (n*m)*v⃗ =n*v⃗ + m*v⃗

Did you mean this instead?

The distributive rule with 2 scalars, 1 vector: (n+m)*v⃗ =n*v⃗ + m*v⃗

(Potentially) Incorrect references to graph locations in I.4

The graphs above should give us a hint. The graph on the left shows us the distribution with a very low standard deviation, where the majority of the values cluster closely around the mean. The graph on the right shows us a higher standard deviation, where the values are more evenly spread out from the average.

I'm viewing the ePub in Google Play Books which stacks the two graphs on top of each other:

nature-of-code-play-books-i4

That makes it hard to figure out which one the text is referencing which it says "on the left" or "on the right". Referencing them using their Figure number would be better.

Extra "example" heading text?

"Example 3-1" appears before "Exercise I.1"

screen shot 2014-06-13 at 11 42 52 am

Is this due to some sort of auto-numbering and the Exercise being listed as an "example"?

<div data-type="example" id="intro_exercise1">
<h5>Exercise I.1</h5>

Typo on page 34

In the print book, at the bottom of page 34 (chapter 1: Vectors), it reads

Then, replacing u and v with their values from Figure 1.6, we get:
wx = 5 + 3
which means that:
Finally, we write that as a vector:
w = (8, 6)

On the online version, this section reads

Then, replacing u and v with their values from Figure 1.6, we get:
wx = 5 + 3
wy = 2 + 4
which means that:
wx = 8 wy = 6
Finally, we write that as a vector:
w = (8, 6)

Coefficient of Drag

Hey there!

When you're explaining the drag force equation, you say "Cd is the coefficient of drag, exactly the same as the coefficient of friction (ρ)". Shouldn't it be μ instead of ρ? Just saying though, not sure! :)

Empty <p> tags

There are lots of empty <p> tags throughout the HTML version. Do I remove these?

typo in introduction

In the code after the text "Taking this further, we could use floating point numbers (i.e. decimal numbers) for x and y instead and move according to an arbitrary random value between -1 and 1." the command

float stepx = random(-1, 1);

should be replaced by

float stepx = random(-1, 2);

Similarly for stepy.

Integrate auto-numbering?

I manually numbered everything, figures, examples, exercises. How do integrate the Atlas auto-numbering system?

This is sort of a duplicate of #4

Vector Propertie Mistake

First of all, thanks for doing this book. I'm in love with it, it's totally awesome, great job!

I think there is a mistake on:

http://natureofcode.com/book/chapter-1-vectors/

at "More Number Properties with Vectors". More specifically at "The distributive rule with 2 scalars, 1 vector: (n_m)_v". Shouldn't it be:

The distributive rule with 2 scalars, 1 vector: (n+m)*v ??? Or am I wrong? If I am, sorry about this ^^

exercise i.6

The initial code for Exercise 1.6 of "The Nature of Code" shows:

  float stepsize = random(0,10);  \\A uniform distribution of step sizes.

  float stepx = random(-stepsize,stepsize);
  float stepy = random(-stepsize,stepsize);

  x += stepx;
  y += stepy;

It seems to me that one would intend for stepx and stepy to have uniform distributions between -10 and 10.

As it stands they have triangular distributions.

Perhaps you intend stepx = random(0,10)*(random sign) ?

figure captions

The figure captions ended up in the alt= attribute. This is a minor problem since there are so few but I need to go through the content and make sure they actually show up as captions.

01_vectors.html line 163

Walk three steps east; turn and walk five steps north.

recommended revision below

Walk three steps east; turn and walk four steps north.

Code Formatting

There is a lot to discuss / work out for code comments and formatting. In the previous version, the book would:

  • parse out code comments to be displayed as separate divs alongside the code (a la Docco / Rocco)
  • included a variety of extra mark-up to help format the code comments [full], [end], [offset-down], [offset-up], [bold], etc.
  • Syntax highlighting for HTML version, none for PDF version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.