How to do three-dimensional drawings?

Here we use Sketch to produce three dimensional drawings. Sketch takes as input a description of the scene, in its own intuitive language, and produces Latex code that can be compiled to produce figures.

Sketch can be downloaded from SourceForge and compiled using:
gcc *.c -o sketch -lm

To test Sketch copy one of the example on the website into a file (I prefer to use the extension .sk for such files) or use the following simplest example (I took it from the Sketch manual).


                    Note that by default Sketch produces PostScript code if you prefer Tikz code add
global {language tikz}
at the end of the file.

Compile the code
./sketch example.sk -o example.tex -T
The option -T tells Sketch to produce an standalone document that you can compile using PDFLatex. If you only want the actual figure code to include it into your code does not use this option. However, note that for documents having several figures it can lead to long compilation times. For other available options use ./sketch -h.

Compile the Tex file to get your figure. It should look like this:
Sketch simple

I found useful to have a standalone figure instead of a whole page for the figure. Therefore, I make some changes to the Sketch output Tex file. If you are interested, compare the original output and the standalone version.