This collection of code was written mainly to create images of
Platonic,
Archimedean and
Catalan solids.
Most calculations are done in Python, and the raytracing is done with
POV-Ray.
da Vinci | direction colors | dual compounds |
The solids with direction colors were created to illustrate Wikipedia articles, while the initial motivation to create the da Vinci solids was to create 3D chess figures. This is essentially code written to be used once, and not a library, but it may be useful for convex polyhedra in general. Unexpected things may happen when the origin is not the center of the polyhedron, or when the normal point of an element is not properly inside of it (like for some parallelepipeds). SymPy does not give correct results for coordinates that are too complicated, like those of the snub cube. (And even if it worked, the calculation would take too long.) Rounded values can be used instead, but this usually means that faces with more than three vertices remain just a collection of triangles. (For the snubs and their duals the wrong edges were removed manually.) The handling of degenerate cases (the polyhedron becomes a polygon) worked well enough where it was needed, but should not be trusted.
The main class in this project is
Polyhedron
,
which is typically initialized with a list of points.
ConvexHull
from SciPy is used to find faces and edges, but it returns just a collection of triangles.
In the next step pairs of coplanar triangles are found and the edges between them removed.
The main methods of this class produce arrays to be used by POV-Ray.
The concept of direction colors has been added to this class after it was finished, and in a rather clunky way.
There are classes like
Polygon
for the other dimensions.
Their methods like __repr__
, __hash__
, __eq__
and __lt__
have been modified
to make it possible to compare ordered lists of these objects for equality.
Examples for the truncated cuboctahedron:
Before (source) and after (source) removing the edges between coplanar triangles | Create polyhedron and print POV-Ray arrays | CSG solid (source) |
For many polyhedra the coordinates along with some radii are found in
utils/polyhedron_properties
.
The code in
1_full_octahedral_group
was used to create illustrations of subgroups for the Wikiversity article
Full octahedral group.
The vertices of the truncated cuboctahedron correspond to elements of this group,
and the convex hulls of these vertices for each subgroup are created here.
A light gray vertex in the origin has been added to degenerate polyhedra (single faces or edges) that do not contain the origin. But the code to do that has been removed. So has the code that handled polyhedra degenerated to single edges.
This code was used to create Platonic, Archimedean and Catalan solids (as well as some chamfers) in which corresponding elements have the same color. Elements containing a 2-fold symmetry axis are blue. For solids with octahedral symmetry 3-fold is yellow and 4-fold is red. By default these solids are shown with the same midsphere.
In
2a_colors_pov
the POV-Ray files are created along with test images.
(They include the midsphere to verify that the size is correct.)
The actual images are created in a second step in
2b_colors_png
,
where these files have been turned into templates.
(For the snubs and their duals the templates contain substantial manual improvements.)
The templates take the variable Factor
, which decides how big
the solid will be. This handling of different sizes is necessary because of a few solids like the
cuboctahedron and the
rhombic dodecahedron.
Apart from the representation with the standard midsphere they are also needed as
core and
hull of the
compound of cube and octahedron.
Which size is rendered depends on the value of image_set
in
run.py
.
The POV-Ray include file polyhedra_colors.inc
is generated from
polyhedra_colors_include.tpl
before the image is rendered.
It contains camera_position
and related values, depending on which value is set for perspective
in run.py
.
(povray_includes/polyhedra_colors.inc
is the version for the standard perspective.)
The finished POV-Ray files are in
2b_colors_png/finished_pov
.
(Those in
disdyakis
are created manually, but use code segments from the older files.)
This code was used to create renderings of wooden polyhedra similar to drawings by Leonardo da Vinci.
The POV-Ray functions used to create them are in
povray_includes
, along with more documentation.
In
3a_davinci_pov
the POV-Ray files are created along with test images.
Manually improved versions of these files are then rendered in
3b_davinci_png
.
For most solids only the size and the offsets have been changed,
but substantial changes where necessary for the snubs and their duals.
Their normal points have been created in
misc/create_snub_normal_points
.
In
3c_numbers
auxiliary images like
this
have been created. They show the index of each vertex (counted from 0)
when the coordinates are in lexicographical order. This is the index in the POV-Ray array P
.
In
4_dual_compounds
images like
this
have been created. The dual polyhedra have the same midsphere.
In
misc/small_in_great_rhombi
some images are created that show the
small in the
great rhombicuboctahedron
with the same edge length,
and the equivalents for tetrahedral and icosahedral symmetry.
See
their category
on Commons.