Skip to content

Instantly share code, notes, and snippets.

@8q
Created April 28, 2019 17:30
Show Gist options
  • Save 8q/3268f687cd11765708015d8286e81202 to your computer and use it in GitHub Desktop.
Save 8q/3268f687cd11765708015d8286e81202 to your computer and use it in GitHub Desktop.
OpenSCADでへノンアトラクタ
function map(value, start1, stop1, start2, stop2) = start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
module henon_map(x1, x2, y1, y2, zsize, zpos)
{
a = 1.4;
b = 0.3;
ls = [
for(i=0, tx=0.0,ty=0.0,x=0.1,y=0.0;i<22000; i=i+1,tx=1-a*x*x+y,ty=b*x,x=tx,y=ty)
[i, [map(x, -1.5, 1.5, x1,x2), map(y, -0.5, 0.5, y1,y2), zpos]]
];
for(e = ls)
{
if(e[0] > 100)
translate(e[1])
cube([0.05, 0.05, zsize], center=true);
}
}
color("yellow") henon_map(-5, 5, -5, 5, 0.2, 0.5);
color("skyblue") translate([0, 0, 0.2]) cube([10,10,0.4], center=true );
color("black")
translate([0.8, -4.1, 0.3])
linear_extrude(height = 0.375, center = true)
text(size=0.8, "Henon Map", font="Karumbi");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment