Re:Donut math: how donut.c works
by ggambetta on Monday September 18, 2023 @04:44AM
(#37553751)
Deriving the perspective projection equations involves intersecting a ray and the projection plane, but this doesn't magically turn a rasterizer into a raytracer.
- 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:
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.
Further, you can add includes on the command line
Then the source can be left as is.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...
Tangentially reminds me of my own animated GIF app that I made a while ago.
https://www.gifcii.fun
https://www.ioccc.org/years.html#1998_banks
https://www.ioccc.org/1998/banks.orig.c
https://www.ioccc.org/years.html#1998_banks