Skip to content

Instantly share code, notes, and snippets.

@takawo
Created November 15, 2022 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takawo/56af8b9e0bffc17f75dbc7404c475dfd to your computer and use it in GitHub Desktop.
Save takawo/56af8b9e0bffc17f75dbc7404c475dfd to your computer and use it in GitHub Desktop.
//https://twitter.com/ru_sack/status/775098568298278912
// x=(1+sin(1πu)sin(1πv))sin(4πv)
// y=(1+sin(1πu)sin(1πv))cos(4πv)
// z=cos(1πu)sin(1πv)+4v-2
// 0≦u≦1
// 0≦v≦1
// #数学デッサン
function setup() {
createCanvas(800, 800, WEBGL);
ortho(-width / 2, width / 2, -height / 2, height / 2, -5000, 5000);
}
function draw() {
background(0);
let scl = 100;
orbitControl();
for (let v = 0; v < 1; v += 1 / 80) {
for (let u = 0; u < 1; u += 1 / 80) {
let x = (1 + sin(1 * PI * u) * sin(1 * PI * v)) * sin(4 * PI * v);
let y = (1 + sin(1 * PI * u) * sin(1 * PI * v)) * cos(4 * PI * v);
let z = cos(1 * PI * u) * sin(1 * PI * v) + 4 * v - 2;
x *= scl;
y *= scl;
z *= scl;
push();
translate(x, y, z);
box(10);
pop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment