> Gracias a unas conversaciones con Carlos Román alrededor de sistemas
> dinámicos, he decidido publicar una implementación simple del mapa de
> Hénon basado en un programa de Juan Reyes y Craig Sapp.
>
Hola,
Una simple aplicación del mapa de Henon en Processing:
(instrucciones en el código :-] )
/************************************************************************
*
* So we want to implement the 'Henon Map' to motion in Processing
*
* 07/07/07
*
* juanig_at_CCRMA.Stanford.EDU
*
*************************************************************************
*/
// Global declarations
int ydir = 1; // up and down
int xdir = 1; // right and left
float xpos, ypos;
float accel=0.5; //acceleration
// Initialize Henon Values (they are global because iterations)
float newx = 0, newy =0;
int normHenonx=0, normHenony=0 ;
float x = 0.63135448, y = 0.18940634;
// Try to leave x and y values as is.
// Once you get good results, you can change them.
/*************************************************************/
// setup
void setup()
{
size(256,256);
noStroke();
frameRate(4);
smooth();
}
// Draw after setup
// Actual draw function
void draw()
{
background(85,90,100);
println (normHenony);
HenonFn();
normHenonx=NormVal(newx);
normHenony=NormVal(newy);
bounceBall();
}
/*************************************************************
*
* Normalize Henon values as per:
*
* Y = floor [ ( (X+1) / 2) * 512 ]
*
* where: Offset=1, MaxIn=2 (Henon Map Maxima),
* MaxOut=512 (Output Maximum)
*
*
*************************************************************
*/
int NormVal (float input)
{
int output;
output = floor (((input +1) / 2.00) * 100);
return output;
}
/*************************************************************
*
*
* Functions (a.k.a as Methods)
*
* HENONFN: x(n+1)= ax(n)^2 + bx(n-1) + 1
*
* x(n+1) = 1 + ax(n)^2 + by(n)
* y(n+1) = x
*
*************************************************************
*/
void HenonFn()
{
//% Henon a and b values can be as:
//% Periodic signal: a=-1.4; b=-0.3;
//% Cuasi-periodic signal: a=-1.77; b=-0.01;
//% Chaos until finds stability: a=-1.01; b=-0.09;
//% Try changing a and b values to get different motion
// float a=-1.77, b = -0.01;
float a =-1.85039, b = 0.00393701;
//
newx = (a*(x*x)) + (b*y) + 1;
newy = x;
x = newx;
y = newy;
}
void bounceBall()
{
int maxh=(height-32);
float maxw=(width-32);
float ox, oy, px, py, qx, qy;
xpos=normHenonx+(1.0*accel);
ypos=(128-normHenony)+(1.0*accel);
// Test for bounds inside drawbox
if (xpos > maxw)
{
xpos = width/2;
}
if (ypos > maxh)
{
ypos = height/2;
}
// Get origins for different balls
ox = (maxw-xpos);
oy = (maxh-ypos);
px = (maxw-(128-xpos));
py = (maxh-(ypos+64));
qx = (maxw-(192-xpos));
qy = (maxh-(ypos+64));
// Draw balls
ballblue(ox,oy);
ballred(px,py);
ballgreen(qx,qy);
accel=accel+0.001;
}
void ballblue (float posx, float posy)
{
fill(64,0,150); // (35,0,150)
ellipse(posx, posy, 50, 50);
fill(255);
ellipse(posx, posy, 20, 20);
}
void ballred (float posx, float posy)
{
fill(242,11,64);
ellipse(posx, posy, 50, 50);
fill(255); // (35,0,150)
ellipse(posx, posy, 20, 20);
}
void ballgreen (float posx, float posy)
{
fill(74,130,64);
ellipse(posx, posy, 50, 50);
fill(255); // (35,0,150)
ellipse(posx, posy, 20, 20);
}
_______________________________________________
____ ____ ___ ____ _ _ ___
|__| |__/ / |___ \/ |__]
| | | \ /__ |___ _/\_ |
arzexp mailing list
[email protected]
http://lists.slow.tk/listinfo.cgi/arzexp-slow.tk