4 ms·
Donut math: how donut.c works
- enigmarc 3y agoInteresting. Tangentially reminds me of my own animated GIF app that I made a while ago. https://www.gifcii.fun https://www.gifcii.fun
- mkii 3y agoThis is seriously cool
- munchler 3y ago(2011)
- Agingcoder 3y agoThat’s the kind of thing that had me learn coding many years ago ( watching demoscene productions).
- supportengineer 3y agoWhat platform does this compile on? Didn't work for me on a recent model M1 MacBook Pro.
- physicsguy 3y agoWhat were the errors?
- unwind 3y agoI got it to compile in Linux on x86-64, with the following tiny changes: - Add #include <stdio.h> (for printf()) - Add #include <string.h> (for memset()) - Add "int" before the initial bare declaration of "k" I compiled it with: $ gcc -o donut -std=c89 donut.c -lm Which includes: - Specifying an old language standard to get rid of the need to say "int" before main() - Linking the math library ("-lm") for the trig functions. Update: minor grammar and clarification.
- stabbles 3y agoWith -std=c89 you shouldn't need that `int k`, right? Further, you can add includes on the command line cc -std=c89 donut.c -include stdio.h -include string.h -include math.h -lm Then the source can be left as is.
- ptspts 3y agoIt should compile without the #includes, possibly didplaying some compiler warnings.
- forgotpwd16 3y agoYeap. A gcc -lm donut.c is enough. Also type and return type default to `int` so this doesn't need change either.
- jheriko 3y agoreminds me of stuff i based in basic when i was a kid made me laugh to see "no raytracing", then immediate use of the perspective projection which is intersecting points and a plane along a ray lol...
- waveBidder 3y agoit's boutique hand-derived ray tracing! very different
- ggambetta 3y agoDeriving the perspective projection equations involves intersecting a ray and the projection plane, but this doesn't magically turn a rasterizer into a raytracer.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- ryandv 3y agoReminds me of this classic IOCCC entry implementing a flight simulator, where portions of the source code are formatted to resemble a plane: https://www.ioccc.org/1998/banks.orig.c https://www.ioccc.org/1998/banks.orig.c https://www.ioccc.org/years.html#1998_banks https://www.ioccc.org/years.html#1998_banks