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.
IndexProgramming Questions & HelpSyntax Questions › curves chapter in Processing handbook
Page Index Toggle Pages: 1
curves chapter in Processing handbook (Read 311 times)
curves chapter in Processing handbook
Feb 8th, 2009, 3:09pm
 
hey there,

I am working through Ben and Caseys Processing handbook. I'm pretty new to programming and have become stuck on one of the exercises on page 84. I am sure the solution is simple... please help if you can.

It is to do with converting equations to create curves. I have tested the following equation:

y = x^n

with this code as explained in the book:

for(int x = 0; x < 100; x++){
 float n = norm(x, 0.0, 100.0);
 float y = pow(n, 4);
 y *= 100;
 point(x, y);
}

I am now trying to complete the exercise of converting the equation:

y = 1 - x^4

How do I do this? I have experimented with the lerp() function and map but I am going a little crazy. Please help if you can.

Re: curves chapter in Processing handbook
Reply #1 - Feb 8th, 2009, 4:21pm
 
What about:
float y = 1 - pow(n,4)?

and otherwise you could make a help-variable:
float helpY = pow(n,4);
float y = 1 - helpY;
Re: curves chapter in Processing handbook
Reply #2 - Feb 8th, 2009, 4:27pm
 
TVS wrote on Feb 8th, 2009, 4:21pm:
What about:
float y = 1 - pow(n,4)

and otherwise you could make a help-variable:
float helpY = pow(n,4);
float y = 1 - helpY;


of course. What a muppet I am. Struggled abit with the emd of this chapter. Thanks for the help.
Page Index Toggle Pages: 1