# Most solid

Yusuke Endoh
mame@tsg.ne.jp

## Judges' comments:

### To build:

    make endoh4

### To run:

    ./endoh4

### Try:

NOTE: The author recommends the use of xterm.

    ./endoh4 < cube.txt

For example, if you are a soccer fan, try:

    make all
    ./endoh4 < solids/archimedian-solid/a11-truncated-icosahedron.txt

### Selected Judges Remarks:

This program is formatted as the net for a tetrahedron. (hint, try feeding the program it’s own source code). When it runs there is an animation for the computation to work out the convex hull.

## Author’s comments:

### Spec

This is a convex polyhedron viewer, which:

1. reads three-dimentional vertices (3N float values) from stdin,
2. calculates a convex hull of them, and
3. renders it.

This simple spec involves many details.

- 3D convex hull calculation
  - recursive gift wrapping algorithm
  - automatical merging of (almost) co-planar faces (i.e., faces are not triangulated)
  - random perturbation for robustness
- 3D rendering
  - perspective projection
  - ASCII line drawing: `"',;;;,;'"`
  - camera in a spherical spiral orbit

(Note that this program does not use `math.h`.)

### Portability

I think it conforms with both C89 and C99. I confirmed that it worked on gcc, clang, and tcc. It should not be warned with -pedantic and -Wextra.

### Tips

You may want to use `tput` to hide a terminal cursor.

    tput civis
    ./endoh4 < cube.txt
    tput cnorm

### Bonuses

You can change the screen size. Let the aspect ratio be about 3:1.

    gcc -DS=120,40 -o endoh4 endoh4.c

The shape of this code is the geometric net of a regular tetrahedron. So, try:

    ./endoh4 < endoh4.c

The solids.tbz2 file includes various solid data: Platonic solids, Archimedean solids, Prisms, Antiprisms, Bipyramids, Trapezohedrons, and Johnson solids.

I created the files by using the POV-Ray scripts (1 and 2) in Wikipedia. They are copyrighted in CC BY-SA 3.0 by “User:Cyp” and “User:AndrewKepert”.

| © Copyright 1984-2013, Leo Broukhis, Simon Cooper, Landon Curt Noll - All rights reserved This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. |