We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Basic Programming Math (Read 2102 times)
Basic Programming Math
Sep 17th, 2009, 10:29am
 
Heya...

Just after seeing this thread here: http://processing.org/discourse/yabb2/num_1248985059____got_me_thinking____I_share_the_sentiments_of_this_poster___.html

Sometimes, when using the Reas/Fry Processing book... I've had some kind of realisation to do with the code that was mathematical, and not necessarily syntactical.

For instance...

examples in the book present iteration...

such as

Code:
for(int i = 20; i < 150; i += 10) {
   line(i, 20, i, 180);
 }


and also motion, as in

Code:
float y = 0.0;

void draw() {
 frameRate(30);
 background(204);
 y = y + 0.5;
 line(0, y, 100, y);
}


but for me a lot of the realisation came from the splicing of the two codes together... like so...

Code:

float y = 0.0;
void setup() {
 size(200, 200);
}

void draw() {
 background(190);
 y = y + 0.5;
 
 for(int i = 0; i < 150; i += 10) {
   line(i + y, 20, i + y, 180);
 }
}


... As important as it is to understand things like placing background in draw to clear the screen, and knowing that adding a value to a variable increases that variable by that value each time thru draw... and that setting the conditionals correctly will give the desired results for the iteration... i feel a lot of understanding, for me personally, came from "i + y"...

I discovered "i + y" in an answer to this very problem (combining motion with iteration) on this board... but this kinda thing seems such an important critical thing at such an early stage of programming... but yet receives little explanation... it might sound weak or insignificant... but its the kinda thing that can stump u and put you off coding for a good few weeks...

I'm really surprised there isn't a sort of basic example of "iteration plus animation"...

To me it's these little things that are the real 'aha!' moments when learning to program... but it's very unlikely a beginner programmer would try and mangle code together in that way... let alone understand that adding i & y is combing the iteration with the animation.

I always find it interesting to see what learned programmers take for granted when they teach programming. I myself am hopelessly amateur at programming... But I always try and keep a note on these little things that it seems maybe since they are so insignificant to someone who understands such a basic concept, they end up getting left unsaid.

A lot of Processing's audience is coming in from the "i don't know math but want to learn programming" angle... it declares itself as the language for artists, and it's true, many ditched math in high school... Indeed programming probably gives them a renewed hunger and interest in learning math... as it does for me.

Programming does come across as a great way to learn math. It's got instant value, not just a sum on a page...

I also understand that the reas/fry book is something of an 'intermediate' users book...

I guess I am just saying it's one thing to understand syntax and programmatic concepts, but it's also another to understand what values are doing and how a sum can be explained in terms of elements on screen...

Would be great to see this kind of instruction explored in future processing books/updates...





Re: Basic Programming Math
Reply #1 - Nov 17th, 2009, 2:25pm
 
I see what you mean.

I've just finished the Shiffman book and there are two things I need to develop further. Object-oriented programming and math. Both are crucial I guess. But as a graphic designer I don't have a lot of programming experience in my backpack (for OOP) and also it's been quite some time since actually had to use (complex) math.

On the other hand I see a lot of stuff that is very helpful in books, websites, examples, forums etcetera. But I'll always support a plee for more attention for the non-programmer, non-math-loving crowd

Smiley
Page Index Toggle Pages: 1