During the bicycle wheel building process, once a rim and hub are purchased the next step is to calculate the spoke length. The length is dependent on both components and the spoke lacing pattern.

As with most problems involving circles, we need to draw some triangles and use a couple basic trigonometric functions in order to calculate the length of two lines, $\overline{AD}$ and $\overline{CD}$ below. Those lines represent the spoke length of the drive-side and non-drive side of the wheel. In order to calculate the length of those lines we first need to find the distance from the rim to the hub represented by $\overline{BD}$ and the distance from the center of the hub, which lies halfway between the two lock nuts, to the center of each flange represented by $\overline{AB}$ and $\overline{BC}$.

As depicted in the diagram below, the width of the drive side and non-drive side of the hub will differ because of the space required for the cassette. A hub designed for a fixed or single speed bicycle is symmetric, which means $\overline{AB}=\overline{BC}$ and simplifies the following calculations.

The first step to calculate the length of $\overline{AB}$ and $\overline{BC}$ is to take some basic measurements of the hub, including the flange width, Over Locknut Distance (OLD) represented by $\overline{EF}$ and the width between the lock nut and the outside of flange on each side represented by $x$ and $y$.

$$\overline{AB}=\frac{OLD}{2}-x+\frac{flange width}{2}$$

$$\overline{BC}=\frac{OLD}{2}-y+\frac{flange width}{2}$$

With $\overline{AB}$ and $\overline{BC}$ calculated we focus on the other side, $\overline{BD}$, which is the distance from the hub to the correct spoke hole in the rim, which is dependent on the lacing pattern.

The following diagram demonstrates a spoke laced in a 3-cross pattern. With each cross the spoke moves two spoke holes along the rim. That is because every other hole in the rim is laced to the same side of the hub. In contrast, a radial lacing pattern is represented by $\overline{HB}$.

In order to calculate the length of $\overline{BD}$ we need to draw another triangle represented by $\triangle BDI$. To calculate the length of $\overline{BD}$ we need to find the length of $\overline{BI}$ and $\overline{DI}$.

$$\overline{BD} = \sqrt{\overline{BI}^2+\overline{DI}^2}$$

In order to calculate the length of $\overline{BI}$ we need to calculate $\angle DGH$.

$$\angle DGH=\frac{2\pi}{\frac{n}{2}}\times c=\frac{4\pi c}{n}$$

Next measure the diameter of the flange between opposite spoke holes. That value divided by two gives us the radius, which is represented above as $\overline{BG}$. That length and $\angle DGH$ provide us with enough information to calculate the length of $\overline{BI}$ using the trigonometric sine function.

$$\overline{BI}=\overline{BG}\times sin(\angle DGH)$$

With the length of $\overline{BD}$ still in mind we turn our focus to $\overline{DI}$. I used a couple of spare spokes and a caliper to measure the diameter of the rim between opposite spoke holes. Alternatively, the manufacturer of the rim should list the Effective Rim Diameter (ERD). Either value divided by two gives us the radius, represented above as $\overline{GD}$.

$$\overline{DI}=\overline{GD}-\overline{BG}\times cos(\angle DGH)$$

With $\overline{DI}$ and $ calculated we can finally calculate the length of $ using the Pythagorean theorem.

$$\overline{BD}=\sqrt{\overline{DI}^2+\overline{BI}^2}$$

Alternatively, $\overline{BD}$ can be calculated using $\overline{BG}$ and $\overline{DG}$ in one of the following ways:

$$\overline{BD}=\frac{1}{\overline{DG}}\times sin(\angle DGH)$$

$$\overline{BD}=\frac{1}{\overline{BG}}\times cos(\angle DGH)$$

$$\overline{BD}=\sqrt{\overline{DG}^2-\overline{BG}^2}$$

With $\overline{BD}$ and the previously calculated $\overline{AB}$ and $\overline{BC}$ we can finally calculate the length of the drive-side and non-drive side spokes!

In the above diagram the non-drive side spoke length can be calculated using the Pythagorean theorem. Additionally, since manufactures don't measure the length of a spoke to the center of the spoke holes in the flange you will need to subtract the difference, which can be calculated by dividing the spoke hole diameter by two.^{1}

$$\overline{AD}=\sqrt{\overline{AB}^2+\overline{BD}^2} - \frac{s}{2}$$

Similarity, we can calculate the drive-side spoke length as follows.

$$\overline{CD}=\sqrt{\overline{BC}^2+\overline{BD}^2} - \frac{s}{2}$$

There are many ways of rewriting these equations. A common one may look like the following:

$$L=\sqrt{a^2 + b^2 + c^2} - \frac{s}{2}$$

Given the following two equations derived above.

$$\overline{BD}=\sqrt{\overline{DI}^2+\overline{BI}^2}$$

$$\overline{AD}=\sqrt{\overline{AB}^2+\overline{BD}^2} - \frac{s}{2}$$

We simply substitute $\overline{BD}$ as follows:

$$\overline{AD}=\sqrt{\overline{AB}^2+(\sqrt{\overline{DI}^2+\overline{BI}^2})^2} - \frac{s}{2}$$

$$\overline{AD}=\sqrt{\overline{AB}^2+\overline{DI}^2+\overline{BI}^2} - \frac{s}{2}$$

- Wheel building at the Artisan's Asylum taught by Seven of Nine

I'm not entirely sure why this wasn't done earlier, when calculating $\overline{BD}$↩