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
ButterflyCurve (Read 456 times)
ButterflyCurve
Jul 22nd, 2009, 12:41am
 
there is this great ButterflyCurve
http://mathworld.wolfram.com/ButterflyCurve.html
it would be so great to translate it into processing...
where to start?
Re: ButterflyCurve
Reply #1 - Jul 22nd, 2009, 1:24am
 
I always find this resource helpfull
http://local.wasp.uwa.edu.au/~pbourke/geometry/butterfly/

Anyway, using parts of yesyesnono code, this is it :
Code:

float t;
int NUM_ITER = 13;

void setup(){
size(1024, 768, JAVA2D);
smooth();
background(0);
t = 0.0f;
}


void draw(){
background(255);


for(float t=0.0f; t < TWO_PI*NUM_ITER; t+= 0.002f){
float theta = exp(cos(t)) - 2*cos(4*t) - pow(sin(t/12), 5);
float x = width/2+sin(t)*theta*80f;
float y = height/2+cos(t)*theta*80f;

stroke(0);
point(x-45,y-45);

}
}


maybe you get the idea comparing the code and the formula how it was done and could be transalted. maybe try it with another formular yourself
Re: ButterflyCurve
Reply #2 - Jul 22nd, 2009, 1:39am
 
wow! ...another question; to have it as spline to be able to use fillings and play with the vertex parameters would be perfect.
wouldn't it be possible to make each wing out of 3 bezier points...?
Page Index Toggle Pages: 1