Created
November 15, 2022 08:15
-
-
Save takawo/56af8b9e0bffc17f75dbc7404c475dfd 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
//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