A number of rules have been moved from entry `Makefile`s into the `1337.mk` include file to make it easier for these common rules to be updated or modified globally (by modifying the `1337.mk` include file). The entry level `Makefile`s are now similar in form to the /Makefile.example](https://github.com/ioccc-src/mkiocccentry/blob/master/Makefile.example) file from the other repo. The following make rules were moved into the `1337.mk` include file: - `make indent.c` - `make install` - `make diff_orig_prog` - `make diff_prog_orig` - `make diff_alt_prog` - `make diff_prog_alt` This simplifies the entry level `Makefile`s so that they mostly reflect the specifics of the particular entry. Mentioned in FAQ 4.2, that the make diff rules are in the `1337.mk` include file. Fixed invalid TAB character in `faq.md`. Removed `make clean` directives that removed `indent.c`. This file is now removed via `make indent_clean`, a clean rule that also removes `indent.c`. Removed `make clobber` directives that removed sandwich, This file is now removed via `make indent_clobber`, a clean rule that also removes `sandwich`. Added `make indent_clean` and `make indent_clobber` rules into the top level `Makefile` and the year level `YYYY/Makefile`. Performed `make quick_www` to accomplish the above and to test under macOS.
To build:
make
There is an alternate version of this entry which should work for Windows by
setting binary mode on stdout. See alternate code below.
To use:
./persano p q [num frames]
Try:
./try.sh
Open the GIF files with a viewer capable of displaying animated GIFs and watch closely at the bottom of the picture (you may need to use gifsicle - a great tool to manipulate animated GIFs - to slow down the animation and to compress the GIFs generated by the entry).
Alternate code:
This (untested as we have no Windows system) version uses the Windows API
functions _setmode() and _fileno(3) to set binary mode on stdout which should
let it work with Windows.
Alternate build:
make alt
Alternate use:
Use persano.alt as you would persano above.
Alternate try:
./persano.alt 3 16 > knot3-16.gif
Follow the same instructions, using different tools if necessary, as the above try section.
Judges' remarks:
If your system is one of those that distinguish between text and binary streams, you must know what to do to switch the standard output into binary mode (e.g., adding a line to the source code or specifying a linker option).
What needs to be done to fix the problem?
Solving the author's exercises below may or may not help.
At the time of judging, the approximation of π used in the program could not be found on https://mathworld.wolfram.com.
Author's remarks:
knot writes animated GIF images of rendered torus knots to standard output.
SYNOPSIS
./persano p q [num frames]
DESCRIPTION
A (p,q)-torus knot is a closed,
non-intersecting curve on the surface of a
torus in R3 that winds p times around
one cycle of the torus and q times around the other. p and q should be
coprime; otherwise, the
resulting curve will not be a knot (that is, imagining the resulting curve as
a loop of rubber, there will be a way to bend, twist and stretch it, without
cutting it 1 , until it ends up looking just like a circle embedded in R3 2 ).
Sample usage:
./persano 3 2 1 > foo.gif
writes a non-animated GIF (a single frame) stream of a rendered trefoil
knot to the file foo.gif.
./persano 5 2
writes a GIF stream with a rendering of Solomon's Seal knot to standard output; since the number of frames is not specified, an animation with 40 frames will be written.
Please view the code with 8-character tabs!
OUTPUT FORMAT
The program writes fully valid GIF 89 streams.
It is suggested that the output be viewed with a program capable of displaying animated GIFs, such as almost any graphical HTTP browser.
Due to code size constraints, full LZW compression was not implemented 3 . In fact, the output images are even somewhat expanded, thanks to GIF overhead.
The GIF format supports only a limited number of bits per pixel, so the program uses ordered dithering to emulate full RGB output.
PORTABILITY
The program was tested on Linux, with gcc 3.1; Cygwin, with gcc 3.3; and Solaris/SPARC, with Sun's C compiler.
The only major portability issue should be reliance on ASCII.
It should also be mentioned that the program won't work on systems that distinguish between text and binary streams; however, since hardly anyone uses such systems in this day and age, this is a minor issue. 4
EXERCISES FOR THE READER
-
(1 point) The surface is composed of many small polygons. Try to make it smoother by increasing the number of polygons.
-
(2 points) Figure out how to change the radius of the tube cross section.
-
(5 points) Locate the famous transcendental constant π in the code.
-
You can call such a transformation an "ambient isotopy" if you want to impress people at parties. ↩︎
-
Also known as the "unknot", which sounds slightly less impressive than "ambient isotopy". ↩︎
-
Unfortunately (for the author), the convenient excuse that LZW compression was not implemented in order to avoid the Unisys patent can no longer be used. ↩︎
-
;) ↩︎