Created
August 17, 2020 23:35
-
-
Save Nekodigi/e7fe401e1450be13e7cc3018a137aba6 to your computer and use it in GitHub Desktop.
This file contains 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
//based on this site http://paulbourke.net/geometry/chladni/ | |
float gridS = 2;//10 | |
float m = 5; | |
float n = 1; | |
float hmult = 10;//50 | |
void setup(){ | |
size(500, 500, P3D); | |
//fullScreen(P3D); | |
} | |
void draw(){ | |
//m = map(mouseX, 0, width, 0, 10); | |
//n = map(mouseY, 0, height, 0, 10); | |
m = sin(float(frameCount)/70)*5+5; | |
n = sin(float(frameCount)/50)*5+5; | |
lights(); | |
noStroke(); | |
background(255); | |
translate(0, height, 0); | |
rotateX(10); | |
for(int x=0; x<width-gridS; x+=gridS){ | |
beginShape(TRIANGLE_STRIP); | |
for(int y=0; y<height; y+=gridS){ | |
float px = map(x, 0, width, 0, 1); | |
float py = map(y, 0, height, 0, 1); | |
float px2 = map(x+gridS, 0, width, 0, 1); | |
float h = cos(n*PI*px)*cos(m*PI*py) - cos(m*PI*px)*cos(n*PI*py); | |
float h2 = cos(n*PI*px2)*cos(m*PI*py) - cos(m*PI*px2)*cos(n*PI*py); | |
vertex(x, y, abs(h)*hmult);//use abs for visualization | |
vertex(x+gridS, y, abs(h2)*hmult); | |
} | |
endShape(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment