fix Makefile and README.md for 2012/blakely
This commit is contained in:
1 parent
4b30fbdd67
commit
3d0379b9f6
2 files changed
+240
-114
No files matched your search
+35
-33
@@ -1,28 +1,32 @@
|
||||
# Most GIFted expressions
|
||||
|
||||
Philip Blakely
|
||||
Cambridge, UK
|
||||
<pmblakely@gmail.com>
|
||||
Philip Blakely
|
||||
Cambridge, UK
|
||||
<pmblakely@gmail.com>
|
||||
|
||||
# To build:
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make blakely
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
### To run:
|
||||
|
||||
./blakely "RPN formula" resolution > output.gif
|
||||
```sh
|
||||
./blakely "RPN formula" resolution > output.gif
|
||||
```
|
||||
|
||||
### Try:
|
||||
|
||||
./blakely "xx*yy*+" 64 > paraboloid.gif
|
||||
```sh
|
||||
./blakely "xx*yy*+" 64 > paraboloid.gif
|
||||
|
||||
./blakely 9 32 > empty.gif
|
||||
./blakely 9 32 > empty.gif
|
||||
|
||||
time ./blakely 0 250 > flat.gif
|
||||
time ./blakely 0 250 > flat.gif
|
||||
```
|
||||
|
||||
### Selected Judges Remarks:
|
||||
## Judges' comments:
|
||||
|
||||
Several IOCCC themes (RPN calculator, animated GIF generator, ray tracing) in one package! Very impressive!
|
||||
|
||||
@@ -30,21 +34,22 @@ The checkerboard pattern in the output can be broken. Could you figure out how?
|
||||
|
||||
Larger GIF files confuse some image viewers.
|
||||
|
||||
|
||||
## Author's comments:
|
||||
Remarks
|
||||
-------
|
||||
|
||||
### Remarks
|
||||
|
||||
This program renders a generic RPN expression in ray-traced animated GIF form.
|
||||
The expression in spatial variables x and y is specified on the command-line with the required resolution,
|
||||
and an animated GIF showing a fly-around of the resulting surface is output to stdout.
|
||||
|
||||
Usage
|
||||
-----
|
||||
### Usage
|
||||
|
||||
The program should be run as:
|
||||
|
||||
./blakely xy* 32 > pic.gif
|
||||
```sh
|
||||
./blakely xy* 32 > pic.gif
|
||||
```
|
||||
|
||||
where the first parameter is a RPN expression, and the second is the width of the required GIF, up to a maximum of 250.
|
||||
|
||||
The expressions are written in Reverse Polish Notation with the following characters recognised:
|
||||
@@ -65,42 +70,40 @@ The surface plotted corresponds to -1 <= x,y <= 1 and for best results, the gene
|
||||
|
||||
If there is a division by zero, square-root of a negative number, or similar operation, then the results are undefined.
|
||||
|
||||
Examples
|
||||
--------
|
||||
### Examples
|
||||
|
||||
For test-runs, use a resolution of 32. For simple expressions, the GIF generation should take only
|
||||
a few seconds with a modern processor and full optimization. Run-time scales as O(N^3) with resolution N,
|
||||
and more complex expressions take longer to compute. For example, increasing the resolution of ripple.gif
|
||||
to 250 took ~35 minutes to render on an i7 processor.
|
||||
|
||||
./blakely xy* 32 > saddle.gif
|
||||
```sh
|
||||
./blakely xy* 32 > saddle.gif
|
||||
|
||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
||||
```
|
||||
|
||||
Algorithm
|
||||
---------
|
||||
### Algorithm
|
||||
|
||||
A generic root-finding algorithm to find the point of intersection between a ray
|
||||
and the surface is done using a simple forward search from the eye.
|
||||
In order to make the rendering realistic, both the value of the expression, and its derivative with respect to x and y must be tracked.
|
||||
This is done using an obvious stack-based approach.
|
||||
|
||||
Obfuscations
|
||||
------------
|
||||
### Obfuscations
|
||||
|
||||
Much of the obfuscation is achieved through the use of single-letter variables and #defines.
|
||||
The characters output for the GIF format are generated in myriad and wonderful ways, making use
|
||||
of XOR, return values from putchar, and odd expressions.
|
||||
The layout is in the form of X Y Z.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
### Limitations
|
||||
|
||||
ASCII is assumed since many bytes for the GIF output are generated from characters given in the source code.
|
||||
On compilation a few warnings about parentheses come up when using gcc 4.6.3, and one about no return value from main() (who uses exit codes anyway?),
|
||||
but clang 3.1 emits no warnings.
|
||||
|
||||
Questions
|
||||
---------
|
||||
### Questions
|
||||
|
||||
* Apart from their appearance when computing the RPN expression, sin and cos are not used.
|
||||
How do we then get the correct angles for rotation?
|
||||
@@ -111,11 +114,10 @@ Questions
|
||||
|
||||
(Note that the author may or may not be able to answer all of the above questions.)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
## Copyright:
|
||||
|
||||
(c) Copyright 1984-2015, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
Reference in new issue
Block a user