Settle on four part
Add function writeheader
The Korn shell RayTracer
krt [-s sqrt] [-n nearest]
krt is the beginning of a raytracer written in pure shell.
There is actually nothing particularly korny about it, this is just a reference to my other project kbf.
It is currently compatible with ksh and bash, and probably with any shell implementing the
-s allows to select among three algorithms to calculate the square root of a given number:
All three are implemented in
The default algorithm is
newton and was picked at random.
-n allows to select two methods of finding the nearest approximation of square root:
The first method,
dynamic, is extremely slow and should not be used.
fixed, is the default but required a pre-generated list of squares named
Such a list can be generated beforehand using this helper script:
$ perfect_squares.sh > perfect_squares.txt
For now there are no scene, no floor, no lights, just a hanging red sphere on a blue background. This is the same as section 5 of Ray Tracing in One Weekend.
Here it is:
It took my laptop 47 minutes to generate it.
There is a makefile available, just run
Note that there are no
Either send send GitHub pull requests or send patches on SourceHut.
All the code is licensed under the ISC License.