About

Scam is a set of Scheme modules for making publication quality printable 3D graphics. The name might be a bit daunting, but it falls in a rich tradition among Schemers and Racketeers. It stands for Scheme CAMera. It is geared towards the GNU Guile implementation of Scheme, together with the Cairo graphics library. But, in light of portability, I try to stick to using R6RS as much as possible.

Cairo is an excellent library for creating programmable 2D vector graphics. It is very structured and easy to use, and can write output to many formats including SVG, PDF and PNG. Scam bundles a stack of functions that describe a scene, being a collection of polygons. Each polygon is a collection of sorted vertices and a material. To display the scene Scam projects it to a surface and plots the polygons in (more or less) the right order. It doesn't support proper hiding of unseen polygons yet. Nevertheless, this is enough to create some rather advanced graphics. I used Scam extensively to create the figures in my paper: "J. Hidding, S. F. Shandarin and R. van de Weygaert - the Zeldovich Approximation: key to understanding cosmic web complexity". As an example:

Example of complicated 3D vector graphics.

Why?

There are numerous methods to create fancy 3D graphics on a computer. Sadly, most of them focus on bringing you interactive visualisations through OpenGL. For the printed media (some of us are very oldfashioned) options are limited. Say you want to plot an image of a torus, this can be done using GNU-Plot.

Example of 3D plotting with GnuPlot.

That looks wonderful! However, GNU-Plot has some severe limitations (for those using Python + MatplotLib, it has similar limitations). GNU-Plot doesn't know how to cut a polygon in half, leading to jaggedy edges if the mesh is not uniform. Also we cannot easily shade the surface. A package that can do highly complicated graphics is Mathematica. Try to export a 3D Mathematica plot to .pdf and enter hell. The resulting file is huge, and many printers will hang on trying to print the images. Most important of all, Mathematica is not free software, which would make it impossible for me to reproduce my work once I'm no longer at a University with plenty budgets.

Current state

Scam is not for the weak hearted. At the moment it requires you to know Scheme. (this is a feature, learning Scheme is loads of fun, see these video lectures by Abelson and Sussman!) Most of all, it lacks a GUI, requiring the user to put in camera positions and material properties by hand. Some nifty features Scam supports now:

And some on my whishlist:

the Source

The source code to Scam is available on GitHub. To download Scam say

git clone https://github.com/jhidding/scam.git
to your terminal while sitting at a decent path. The code runs on Guile 2.0 with guile-cairo.

by Johan Hidding, Copyright 2014, Contact me at: