Created
January 17, 2023 23:51
-
-
Save EDDxample/1558847c29fcdecb6beeff715756f044 to your computer and use it in GitHub Desktop.
Processing script to render Thomas' Cyclically Symmetric Attractor (labeled as .java for syntax highlighting)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final float SCALE = 25; | |
int frame = 0; | |
float B = 0; | |
void setup() { | |
size(500,500,P3D); | |
background(0); | |
} | |
void draw() { | |
frame++; | |
background(0); | |
pushMatrix(); | |
scale(2); | |
text("B = " + B, 0, 10); | |
popMatrix(); | |
translate(width/2, height/2, 0); | |
scale(1,-1,1); | |
rotateX(radians(10)); | |
rotateY(radians(frame / 2.0)); | |
stroke(255, 0, 0); | |
line(0, 0, 0, 100, 0, 0); | |
stroke(0, 255, 0); | |
line(0, 0, 0, 0, 100, 0); | |
stroke(0, 0, 255); | |
line(0, 0, 0, 0, 0, 100); | |
stroke(255); | |
drawPattern(); | |
saveFrame("frame_####"); | |
} | |
void drawPattern() { | |
float x = 0.5; | |
float y = 1.0; | |
float z = 0.5; | |
B = (radians(frame / 15.0) + 0.3) / 2.0 * 0.24; | |
for (int i = 0; i < 10000; i++) { | |
strokeWeight(1); | |
point(x * SCALE, y * SCALE, z * SCALE); | |
float dx = sin(y) - B * x; | |
float dy = sin(z) - B * y; | |
float dz = sin(x) - B * z; | |
x += dx; | |
y += dy; | |
z += dz; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment