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.
IndexDiscussionGeneral Discussion,  Status › where to learn math
Page Index Toggle Pages: 1
where to learn math (Read 2751 times)
where to learn math
Jan 16th, 2009, 3:37pm
 
Hi,
I have been working with processing and I can make some 'cool' stuff. but thats as far as i can go. Ok not entirely tru, I can still manage to learn from other peoples code, which is also good.

but then what i would really love to do is bring my own original ideas on paper. meaning, I know exactly what i want, but find it hard to figure out the math behind it.

For instance, I can learn how to make sandpainters from Jared's code, but when I read the code, I find it hard to figure out how he got the equations like:

point(ox+(x-ox)*sin(sin(i*w)),oy+(y-oy)*sin(sin(i*w)));

- Does this happen through trial and error?
- Are there any known mathematics or physics that I am not aware of?
- or is this pure genius at work Smiley?

Coming from pure design background, things like these could be daunting and I am trying to make my way through it and learn as much as I can, so any help or suggestions are greatly appreciated.

Thanks a lot.
Re: where to learn math
Reply #1 - Jan 16th, 2009, 6:14pm
 
I made a point of including a lot of "this type of" math in my book; also check out Ben/Casey's and Dan's, and there are many books in the Actionscript community (especially check out Keith Peters') that cover it as well.

There's also a trig tutorial on this site: http://processing.org/learning/tutorials/trig/
Re: where to learn math
Reply #2 - Jan 16th, 2009, 9:46pm
 
ssdesign, i feel you man. im in the same boat. math is like that part of your dinner you eat last, leaving most of it on your plate...

ira's book does go into the most detail "mathematically" of the three processing books.

shiffman's website, "nature of code", has some nice paragraphs about math, too.

i thought i saw another processing book that will be published later in the year dealing with "algorithms".


-0.


Re: where to learn math
Reply #3 - Jan 16th, 2009, 10:54pm
 
I believe they are built from components, but they are obfuscated by lack of annotations and terse codes.  A lot of programs are rendered unreadable by clever coding.

I do wish there was a magical parser that'll translate all the trig identities and common greek notations to plain English, though.  But until then, we have to dissect it bit by bit by encapsulation.

Re: where to learn math
Reply #4 - Jan 19th, 2009, 9:59am
 
Hi Ira,
Thanks, your book is on my list to purchase Smiley

I think there must be something more out there which is more about mathematics of iterative painting Smiley or something like that.

I found some of the javascript code from spirograph very useful.
Re: where to learn math
Reply #5 - Jan 20th, 2009, 3:08am
 
to make formulas like that you just have to understand the fundamentals. know how sin will behave as i increases. its not really complicated, i've done some formulas like that and im no trigonometry expert. but once you understand that, you can start applying sines and cosines to get the kind of number progressions you are looking for. then you start multiplying sines and adding cosines and subtracting here and multiplying there and then once you know it, you get big ass formulas that other people will look at and wonder how on earth you got there, but following the reasoning that got you there its usually simple. (hope this makes sense!)

and you can learn a lot from wikipedia, anything specific you want to know is there (what is a sine or a cosine or a tangent, etc...), and keith peters has some really nice books and tutorials, most of them are for flash but are still really useful and easy to understand/convert to procesing.
Re: where to learn math
Reply #6 - Jan 30th, 2009, 3:49pm
 
Some meta-stuff on learning and coding maths. To start, don't ever expect that the process will go like this:

1. Learn the math

2. Code.

In my case, this is what really helps:

* review anything I've forgotten or can't quite remember. (For a lot of us, maths is a muscle that wastes - if you don't use it every day, you'll probably find you need to go back and figure out e.g. what that 'sohcahtoa' thing was good for again!)

* Try using pen/pencil and paper. After a while, some stuff you'll just be able to code - but old fashioned pencil and paper is really helpful, at least for me. Armed with Google, pen, paper and Processing you should be able to learn a lot of what you need.

* Have a document (I just use Word) that you can use for combining planning and whingeing. A kind of geek field diary. I can't code without doing this: I use one section for bullet-pointed pseudocode and another for venting and figuring out where I'm trying to get to.

* Write up your final coding solution in your code comments. Aim for concise but thorough. You will thank yourself later (and other people will like reading your code too.)

* If you're coding a function with many parts, it may help to start by separating them into smaller variables first: you can stick it all into one line (as below) later once you know each part is working.

An example from my last experiment:

http://www.personal.leeds.ac.uk/~gy06do/processing/ces_function

meshPoints[l][k] = pow( (a* pow( ((inputMax/float(meshSize))*k), p ) + ((1-a) * pow ( (((inputMax/float(meshSize))*l)) , p)) ), (s/p) );

Bleurgh! This was from an equation that I'd entered in Maple, which - as you'll see from the code comment - looks like:

(a*k^p+(1-a)*l^p)^(s/p)

Which is a CES function:

http://en.wikipedia.org/wiki/Constant_elasticity_of_substitution

Don't worry about what it does. The point is, the line I took through learning the function and getting to a code version of it was slow. This is rarely emphasised in stuff you read: if you're not used to it, it can appear that you're expected to read maths just like English and code it like some kind of math-channelling wizard. Not true. A great guide here:

http://web.stonehill.edu/compsci/History_Math/math-read.htm

To quote:

"Reading mathematics too quickly results in frustration.  A half hour of concentration in a novel might net the average reader 20-60 pages with full comprehension, depending on the novel and the experience of the reader.  The same half hour in a math article buys you 0-10 lines depending on the article and how experienced you are at reading mathematics. There is no substitute for work and time.  You can speed up your math reading skill by practicing, but be careful.  Like any skill, trying too much too fast can set you back and kill your motivation."

That last point is spot on: don't expect too much of yourself or you'll lose motivation. Go slow. And be thankful for Processing, which is an exemplary way of learning maths and coding!
Re: where to learn math
Reply #7 - Feb 1st, 2009, 5:19am
 
A good book for ideas is:
Computers, Pattern, Chaos, and Beauty
by Clifford A. Pickover
It has a huge variety of computer generated graphics ideas, the math behind them, and pseudocode for the code. It is easy to translate into usable code in the language of your choice.
Re: where to learn math
Reply #8 - Feb 1st, 2009, 10:47pm
 
thanks for the post Dan_Olner.... some good tips in there.
Re: where to learn math
Reply #9 - Feb 18th, 2009, 9:34am
 
A good site that I used to surf a lot, looking for interesting curves for motion tweening (but it's in French) :
http://www.mathcurve.com/
Re: where to learn math
Reply #10 - Feb 18th, 2009, 9:41pm
 
Back in the Dark Ages, when I had the free time of a high school student and my CPU was measured in kilohertz rather than gigahertz (think about that for a second), I did a lot of dinking around with plotting math formulas.

Sounds geeky, but there wasn't much else you could fit into the computer in those days.

So, I did lots of experimenting with polynomials and trig functions, just to see what would happen.  Just to see what cool patterns I could put onto the screen.

Trig functions are a very fertile ground for experimentation, because their inherently cyclic nature leads to lots of repetition.

You learn quickly that the point (r*cos(theta), r*sin(theta)) is a circle. But circles get boring.  

So what happens if you add ANOTHER trig-set on top of that?  What does (r1*cos(theta1)+r2*cos(theta2), r1*sin(theta1)+r2*sin(theta2)) produce?  What happens as you change the relative rates at which theta1 and theta2 advance?  What happens if you turn r1 and/or r2 into functions of theta also?

The variations are endless.

After a while of doing this, not only have you had a lot of fun but you also develop an intuitive sense for how to turn an idea into math.  You start to say to yourself "I'll bet if I changed the formula like _this_, it would look like such-and-such."  And you turn out to be right.

You'll develop to the point where you start asking yourself questions that are beyond the math you know.  That's when you hit Wikipedia to learn (or in most cases, re-learn stuff you've forgotten since high school or college) about the pythagorean distance formula, how to calculate the distance from a point to a line, how to calculate the slope of a line or the tangent of a curve, and on and on.

You'll be learning new math in service of a piece of art you want to create or a problem that you _want_ to solve, which is a wonderful experience that is absolutely not present in the classroom setting of solving problems because they've been assigned as homework.
Re: where to learn math
Reply #11 - Feb 19th, 2009, 3:19am
 
Great thoughts coming up here.

So far, my take away is, start from point 'A' and  keep on creating your own path, in the end destination point 'B' will be a pleasent surprise Smiley
Re: where to learn math
Reply #12 - Feb 19th, 2009, 9:30am
 
Personally, I love maths, although maths doesn't like me. Smiley
I mean that my mind isn't very good at handling very abstract stuff, it is a visual mind. High level maths I (tried) to learn in (preparation) school after baccalaureate (certificate got after 18) were mostly high over my head.
But simple maths manipulated in Processing: arithmetic, trigonometry, geometry, statistics, etc. are OK. It can become harder with 3D or physics, but it isn't so hard.
What is nice with Processing is that you are able to quickly visualize the maths, see if something is wrong, play with formulae, tweak them, etc.

Your example, using a sine of sine, looks more like an experiment (what if...) than a real world formula, unless I miss something, which is probable anyway... Smiley

Looking at my local library, I saw a number of accessible math books, showing them in a playful side, with lot of illustrations and simple terms.
Don't feel silly to get them and read them, I am sure they can help a lot, and are the entry point for more complex books. And hey, at a library, if the book doesn't please you, you just bring them back and try another! Smiley
Re: where to learn math
Reply #13 - Mar 4th, 2009, 12:53pm
 
Just found a great website:

http://betterexplained.com/

Which has these intro posts for maths -

http://betterexplained.com/articles/how-to-develop-a-mindset-for-math/

http://betterexplained.com/articles/developing-your-intuition-for-math/

My favourite line:

"Don’t stop until it makes sense, or that mathematical gap will haunt you. Mental toughness is critical — we often give up too easily."

I don't think it's mental toughness that's needed: just kindness to yourself. I often get cross that I can't learn something instantly that should, by rights, take a few weeks at least. I think "show yourself kindness and understanding" might be more appropriate!
Page Index Toggle Pages: 1