The usual, boring, spoke length calculators allow only the same number of
hub holes, rim holes and number of spokes. What a waste of life and inteligence! This is a thing of the past. The times
when it was important
that a good bicycle
wheel lasts few decades without breaking a spoke are definitely gone. The new
trend is esthetics above functionality; and this requires
to be able to build a wheel with any kind of combination of holes and spokes. This is where I jump in. What you will get
here is a spoke length calculator (as well as wheel building motivator) for any
number and combination of holes, spokes, cross
patterns.
I’ll give more detail. Parts of
the wheel are hub, rim and spokes. The hub has two flanges, left and right, each having half the total number
of hub spoke holes. This also defines
the left and right side of the wheel.
The holes on the left and right flange are oﬀset by an angle; if that wouldn’t be the case, we could not have radial
spokes on both sides of the wheel. The spoke holes in the rim, however, are
less obviously divided to left and right and it is important not to confuse
the total number
of rim holes with the number corresponding just to one side of the wheel. Further,
spokes might be inclined
out of the radial direction
for some angle 
this is usually expressed as a crossnumber C, the number of spokes on one hub flange
that a certain spoke crosses. Radial spokes don’t cross any other spoke, so they have cross number C = 0. When C is not 0 we might have two kinds of spokes on the same side of the wheel:
leading spokes and trailing spokes.
The first ones are inclined clockwise, the others counterclockwise. And finaly, you might not want to (or could
not) use all the holes in the hub or in
the rim. We will consider all of
these possibilities.

Figure 1. Schematical model of a Wheel. 
Figure 1 shows a wheel schematicaly. Point O is the center
of the wheel. Line HR represents a radial spoke that goes through
hole H in the hub and hole R in the rim and has inclination angles
α = β = 0 to the x
axis. If the effective rim radius is R_{r} = OR, and hubhole radius
is R_{h} = OH, then the length
of radial spoke would be S_{0} = R_{r } R_{h}. Line AB represents nonradial spoke. It’s starting
inclination angle is α and
ending inclination is β. Note that AB
is a projection of the spoke to the plane xy.
We have to take into account that spoke has a
component in z direction. If H_{z}
is a dimension from the hub flange to the center of the rim (figure
2), then the spoke length is straightforward to calculate:
L_{AB }2 = (B_{x} − A_{x})2 + (B_{y} − A_{y})2 + H_{z}2 = R2 + R2 + H_{z}2 − 2R_{r}R_{h} cos (β − α)

Figure 2. Hub with indicated dimension Hz . 
The unique
way to describe a general wheel is to assign the starting hole in the hub A and the ending hole in
the rim B to every spoke. We define
the parameters of the wheel: H_{h} is the number
of hub holes in one
flange of the hub, H_{r} the
total number of rim holes (i.e. all the holes in the rim), and S the number
of spokes in one flange of the hub. With these parameters we build
one side  left or right
 of the wheel. Number of
spokes on left and right
side of the wheel might be diﬀerent; if that is the case, we use notation S_{l} and
S_{r}.
For each spoke i , (i = 1, 2, ..., S) we note two indexes: the number of the hub hole A_{i} and
the number of the rim hole B_{i}. We count hub and rim holes in a counterclockwise direction starting at position β = α = 0 with hole number
1. Index B_{i} could
have zeros, negative
numbers, or numbers bigger then H_{r} when
C > 1. This
is OK when calculatig the spoke length,
but for the hole count it is more practical
to have only positive numbers in the range 1 to H_{r}; therefore we might add H_{r} to the zero
or negative number
and subtract H_{r}
form numbers greater
then H_{r}. Using notations ∆α = 2π/H_{h} and
∆β = 2π/H_{r} for
angle segments in the
hub and rim respectfully, we have
the equation:
L_{i} 2= R2 + R2 + H2 − 2R_{r}R_{h} cos (∆β(B_{i} − 1) − ∆α(A_{i} − 1))
which
defines spoke length for any spoke i and any possible wheel composition.
The key point is to define indexes A_{i}
and B_{i}.
We can define them
individually, without calculation, ”by hand”.
Automatism is, however,
much appreciated, especially in later years of your life. That is why I wrote
a program wheel that calculates indexes A_{i} and B_{i}, spoke
lengths, draws a wheel and makes a finite element model for the calculation of stresses in the wheel.
Indexes A_{i} and B_{i} are
calculated as follows.
We would prefer the spokes to be equally distributed over the hub, with constant angle segment ∆γ = 2π/S. We first find A_{i} =
j, i.e. a hole j in the hub which has the closest angle to the angle (i − 1)∆γ
of ith spoke:
A_{i} = MIN_{j} (i − 1)∆γ − (j − 1)∆α, j = 1, ..., H_{h}
In similar manner, we
would find B_{i} = k:
B_{i} = MIN_{k}
ϕ + (i − 1 + (−1)^{i}^{+1}C)∆γ − (k − 1)∆β, k = 1, ...,
H_{r}
ϕ = π/H_{h} is the offset angle between the holes on the left and right flange of the hub. We must add this angle when calculating the right side of the wheel, but not for the left
side.
Example 1. Let’s first give a simple
example: the regular
wheel. It has H_{h} = S = N = H_{r}/2, ∆α = 2π/N ,
∆β = ∆α/2 and arbitrary cross number C. Spoke indexes are, in compact notation: A_{i}
= i and B_{i} = 2(i +(1)^{i}^{+1}C) 1, and the diﬀerence in the angles is:
∆β(B_{i} − 1) − ∆α(A_{i} − 1) = (−1)^{i}^{+1}C∆α
With numerical data for
a 32spoke wheel, R_{r} = 298 mm, R_{h} = 26, H_{z}
= 20 mm and N = 32/2 = 16, we get spoke lengths
(in mm) on one side of the wheel: 272.7, 274.9, 280.9, 289.7 and 299.8 for C = 0, 1, 2, 3, 4
respectfully. All the spokes on one
side of the wheel have the same length. The other side of the wheel could have
different spoke length, because of diﬀerent
dimension H_{z} or different C (figure 3).

Figure 3. 32spoke wheel. Hh = 16, Hr = 32. Left side 16 spokes, cross 2. Right side: 16 radial spokes. Wheel seen from the left side. Spokes on the left side are drawn with solid lines and with dashed lines for the right side. Blue for leading and red for trailing spokes. Rim and hub holes are numbered. 
Example 2. Now, let’s
present a more complicated case. I have recently built a rear wheel for my fixie with
32hole hub, 36hole rim and 16 spokes
for the whole wheel, which means with parameters H_{h} = 16, H_{r} = 36, S = 8 (figure 4, left side).
Not unexpectedly however,
one spokes broke after
about 200 km and another one after
another 200 km.
I made a finite element analysis of the wheel with beam
elements. Loading was 500 N vertical gravitational force and 250 N horizontal force in the
chain acting on the edge
of the hub. The stress
analysis showed that the stress in the spokes was f =1.63 times
greater than the stress would
be in an ordinary 32hole Wheel.
I experimented with different wheel parameters and as a first solution
I added 4 spokes to the right side of the
wheel (figure 4, right), which reduces the factor to f=1.17. The experiment is still ongoing. I will ride with this wheel until possibly the
next spoke breaks, and then decide about the new wheel configuration.

Figure 4. Fixie rear wheel, Hh=16, Hr=36. Left: 16 spokes. Right: 20 spokes. 

Figure 5. My fixie. Both hubs have 32 holes. Front wheel: 24hole rim and 16 radial spokes. Rear wheel: 36hole rim and 20 spokes, mostly cross 2. 