Please log in (or register) to post a dweet (copy-paste the code somewhere safe to save it meanwhile)

u(t) is called 60 times per second.
t: Elapsed time in seconds.
S: Shorthand for Math.sin.
C: Shorthand for Math.cos.
T: Shorthand for Math.tan.
R: Function that generates rgba-strings, usage ex.: R(255, 255, 255, 0.5)
c: A 1920x1080 canvas.
x: A 2D context for that canvas.

Yes. The math constructs a ray from (0,8,8) looking at (0,0,0), varied a bit depending on the pixel being drawn, its length is a function of n. I plug this into the equation for a torus and increment n from .7 to -1 until I find a zero of the equation.

Here is a version without much golfing that makes things clearer for(let i=2e3,f=(o,n,x=o*n,y=t/3*n-n,z=4-n)=>z>-1&(x*x+y*y+z*z+3)**2>16*(x*x+y*y)?f(o,n+.01):z;i--;)x.fillRect(i,t*180,f(i/540-16/9,3),3)

u(t) is called 60 times per second.
t: elapsed time in seconds.
c: A 1920x1080 canvas.
x: A 2D context for that canvas.
S: Math.sin
C: Math.cos
T: Math.tan
R: Generates rgba-strings, ex.: R(255, 255, 255, 0.5)

Please log in (or register) to comment.