3 ms·
Here's a more readable version: https://gist.github.com/1073922 https://gist.github.com/1073922
by donut 15y ago
Here's a more readable version:
https://gist.github.com/1073922 https://gist.github.com/1073922
- pavel_lishin 15y agoI kind of want someone to write some readable code that displays a spinning 3D representation of said readable code.
- a1k0n 15y agoA 3D quine? I've considered it. I have a blog post about something completely unrelated to obfuscated C coming up, but maybe after that I'll make an attempt. If nobody beats me to it.
- donut 15y agoI've updated the code to be even more readable, and as an aside, made it more optimal. sin(A) and sin(B) were being computed repeatedly in the most inner of inner loops, which I pulled out, because A and B don't change in the middle. sin(j) and cos(j) was being computed for every i, even though j wasn't changing. And the intensity was being computed even if the pixel was going to appear beyond the buffer (or wasn't going to appear at all because of a closer pixel in the z buffer). I also refactored parts of it, and gave names to some constants which you can tweak for fun. DELTA_I can be increased without apparent detriment to image quality. I can't think of good names for the two constants in the middle of the code though: 2 and 5. Are those the minor and major radius of the donut?
- a1k0n 15y agoRe: repeatedly computing sin(A)/sin(B)/etc: I don't remember why I did that, as it was five years ago, but it was probably intentional just to move code around so it fit within the shape. Or it was an oversight. IIRC, yes, 5 and 2 are the major and minor radii, meaning 5 is the radius of the ring at the center of the donut (a torus of thickness 0, as it were) and 2 is the thickness -- the radius of the circle extruded around the central ring.