Yusuke Endoh

mame@ruby-lang.org

https://github.com/mame/

```
make endoh4
```

```
./endoh4
```

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
```

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.

This is a convex polyhedron viewer, which:

- reads three-dimentional vertices (3N float values) from stdin,
- calculates a convex hull of them, and
- 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`

.)

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.

You may want to use `tput`

to hide a terminal cursor.

```
tput civis
./endoh4 < cube.txt
tput cnorm
```

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-2015,
Leo Broukhis, Simon Cooper, Landon Curt Noll
- All rights reserved |