Created
November 28, 2023 23:33
-
-
Save hellvetica42/be56474a6a94a6a5f3a8f1eb95fd7d94 to your computer and use it in GitHub Desktop.
Mathematical visualization in Processing
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
void setup(){ | |
size(1000, 1000); | |
} | |
float c = 0.5; | |
float mathf(float x){ | |
return x * c; | |
} | |
float radius = 300; | |
int divisions = 100; | |
float divAngle = TWO_PI / divisions; | |
PVector divPos(float num){ | |
float x = cos(divAngle*num)*radius; | |
float y = sin(divAngle*num)*radius; | |
return new PVector(x,y); | |
} | |
void draw(){ | |
background(20); | |
translate(width/2, height/2); | |
noFill(); | |
stroke(255); | |
circle(0, 0, radius*2); | |
for(int i = 0; i < divisions; i++){ | |
float x = i; | |
float y = mathf(x); | |
PVector start_pos = divPos(x); | |
PVector end_pos = divPos(y); | |
line(start_pos.x, start_pos.y, end_pos.x, end_pos.y); | |
} | |
c+=0.01; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment