# Rolling 10s

Pentagonal Trapezohedron, aka a d10.

Why not kick things off with a little bit of geometry? A week or so back Naomi posted a pic on facebook of my whiteboard with some math on it. Every once in a while I get the idea to do a hobby project related to RPGs which inevitably leads to needing models of game dice. Maya and Blender come with platonic solid creation functions included (tetrahedron, cube, octahedron, dodecahedron, and icosahedron - for d4,6, 8, 12, and 20), but they never have one for the d10! Eyeballing it certainly isn't good enough, so I needed to figure out how the solid's parameters relate to each other.

The solid is called a trapezohedron. All of its faces are identical kites. It always has an even number of faces >= 6. The familiar RPG d10 is a 10-sided trapezohedron. A cube is also a 6-sided trapezohedron when viewed along any of the four diagonals that exist between opposite vertices of the cube. In a 3d modeling package, the simplest way to create one is to start with a polygonal prism, rotate the top face by half of the angle between vertices, and then poke the top and bottom faces and move those vertices directly up and down to form the tips. This can be done with any regular polygon as the prism face. Our example will use pentagons since we're building a d10. The most useful parameters for us to control the overall size of the shape are the radius of the initial prisms, and the overall height of the final shape.

Controlling the radius is simple. Create a cylinder with 5 sides and radius $r$. Done. The harder part is knowing how far apart the top and bottom of the prism should be to fit into the desired height-extent, which we'll call $e$. To figure this out, two views are useful.

Orthographic top view, where we can see the relationship between the radius and apothem of polygons that make up the prism faces.

$n$ is the number of sides (5 in this case)

$a$ is the apothem of the polygon that makes up the faces of the prism.

$\Theta = \frac{360}{2n}$

$a = rcos(\Theta)\\a = rcos(\frac{180}{n})$

This is an orthographic side view where one of the faces of the solid is orthogonal to the viewing direction. Here we can see how our height extent $e$ relates to the quantity we can easily control with our modeling software $d$, which is the height of the pentagonal prism.

We can use similar triangles to find an equation for $h$ in terms of $d$

$\frac{d}{r-a} = \frac{h}{a}\\h=\frac{ad}{r-a}$

Then we can place this into our equation for $e$ to find the relationship between $d$ and $e$.

$e=\frac{d}{2}+h\\e=\frac{d}{2}+\frac{ad}{r-a}\\e = \frac{d(r-a) + 2ad}{2(r-a)}\\e = \frac{rd - ad + 2ad}{2(r-a)}\\e = \frac{rd + ad}{2(r-a)}\\e = \frac{d(r+a)}{2(r-a)}$

Solving for $d$:

$d=\frac{2e(r-a)}{r+a}$

And there we have it! If we want our radius and height extent to be 1 for a sort of unit-trapezohedron (with 5 sides), then $d\approx.2111$. We can take it one step further to find $d$ for a trapezohedron of any number of sides $n$, prism radius $r$ and height extent $e$:

$a = rcos(\frac{180}{n})\\d=\frac{2e(r-a)}{r+a}$

Substituting:

$d=\frac{2e(r-rcos(\frac{180}{n}))}{r+rcos(\frac{180}{n})}\\d=\frac{2er(1-cos(\frac{180}{n}))}{r(1+cos(\frac{180}{n}))}$

This could be put into a plugin for python or blender if one day comes where I'm not too lazy to learn those APIs.