TLDR: I would like a formula that can take a vertical coordinate in an unscaled flat profile and map it onto a vertical slice of the surface of a cone, such that things look uniform across the full surface of the cone.
I'm trying to make gears of a whole bunch of different types that have a truncated octahedron profile that is as uniform as possible for each individual tooth. What I'm stuck on at the moment is mapping them to cones (for bevel gears) and toruses (for ring gears).
This is a hollow truncated octahedron, and a filled version of it tiled along a horizontal plane. I'll call this a skin tiling on a horizontal plane, but presumably there's a better name:
Here is a skin tiling on a cylinder:
The creation of this surface is somewhat complicated, but I don't think I need to explain that in order to explain my problem [Interested people can inspect the OpenSCAD code here if they want]. In order to convert from the planar structure to the cylindrical structure with radius $r$ and $n$ teeth per cylinder, I map the tiled X coordinate $t_x$ to the cylindrical angle $\theta$, and the tiled Y coordinate $t_y$ maps directly to the Z coordinate of the cylinder model $m_z$:
$\theta = \frac{2\pi}{n} t_x$
$M = [r sin(\theta), r cos(\theta), t_y]$
Here is a [partial] skin tiling onto the surface of a sphere. As the radius of vertical rings of the sphere reduces, the scale of the truncated octahedron also reduces, resulting in a tiled pattern that has a smooth scaling and always has the same number of teeth around the ring (i.e. it's conformal):
I had quite a lot more trouble working this one out, until I found the answer on the Wikipedia page for the mercator projection. What I ended up needing was an inverse mercator transformation to map a vertically-infinite plane onto the surface of a sphere (because the radius of the sphere collapses to zero at the poles):
$\theta = \frac{2\pi}{n} t_x$
$\phi = 2 \times tan^-1(e^\frac{t_y}{r}) - \pi/2$
$M = [r sin(\theta) cos(\phi), r cos(\theta) cos(\phi), t_y sin(\phi)]$
I thought that once I had the sphere equation, everything else I wanted would just fall out... but this doesn't seem to be the case. I don't know if I'm missing something really obvious, or if this is actually a hard problem.
So... what I'm currently trying to wrap my head around is a skin tiling onto a cone:
I understand that the equation should involve something that tends to an infinite scale at the smaller radius, so I expect it would have some similarity to the spherical transform, but nothing like that's come out in what I've tried. Here's what is my best attempt so far:
I got this by attempting to work backwards from relationships between the model Z coordinate $m_z$ and the cone surface distance $g$ (assuming a cone with contact angle $\rho$ (relative to the vertical), integrating the scale distortion at a particular Z height, then finding the roots of the resultant quadratic:
$r_z = r_0 - m_z tan(\rho)$
$r_z = r_0 - g sin(\rho)$
$t_y = \frac{1}{r_0} \int{r_0 - g sin(\rho)}{dg}$
$t_y = \frac{1}{r_0}(r_0 g - \frac{1}{2} g^2 sin(\rho)$)
$g = \frac{r_0 \pm \sqrt{r_0^2 - 2 sin(\rho) t_y r_0}}{sin(\rho)}$
$m_z = g cos(\rho)$
But, as you can hopefully see in the image, this results in a substantially distorted mapping, where the bits at the bottom of the cone are too stretched out, and the bits at the top of the cone are too tall and narrow.
Can anyone help me out in working out where I've gone wrong?








After writing this question out, I re-read this bit:
On a hunch, I tried plugging in the same equation:
$\rho = 2 \cdot tan^-1(e^\frac{t_y}{r}) - \frac{\pi}{2}$
$m_z = \frac{2 \cdot\pi \rho}{n}$
The skinned cone is substantially improved, but there's still distortion happening. I set the model to 10 levels of gear teeth to make the distortion really obvious:
I've now found what appears to be a conformal mapping for $\rho = \frac{\pi}{2}$, taking inspiration from the Logarithmic spiral concept mentioned in @jean-marie's answer. I suspect that this will help a lot in leading me to the correct solution:
$m_z = 0$
$r = r_0 \cdot e^\frac{-t_y}{n}$
I suspect what I'll end up with is something that scales between the $\rho = 0$ solution and the $\rho = \frac{\pi}{2}$ solution based on the angle $\rho$.
Update: solved!
I added a thin red cylinder at the reference diameter $r_0$ (in the middle of the gears) to make it a little bit more obvious what's going on:
What I needed to do was modify the exponent of the logarithmic spiral function so that it transitioned from 0 at a vertical angle of 0 to 1 at a vertical angle of $\frac{\pi}{2}$. The sine function, in other words. I then took the result of that, subtracted it from the reference radius $r_0$, and played around with scaling by other trigonometric functions until I found the right one (i.e. tan):
$r = r_0 \cdot e^{\frac{-t_y}{n} \cdot sin(\rho)}$
$m_z = \frac{r_0 - r}{tan(\rho)}$