I recently re-read Jobst Brandt's book the Bicycle Wheel and it inspired to me make a wheel-related post (as well as hand-build some 36 spoke wheels with Mavic MA2 Rims). So I got on my computer and made some basic wheel building tools.
If you've ever built a wheel, you know that before you can begin, you need to calculate the length of spokes to use. I wrote some MATLAB code that calculates the spoke length you need for a given rim and hub combination. If you have MATLAB, then you can paste the following text into an m-file and run it as a spoke length calculator. Otherwise, if you are a computer nerd, I think that C & C++ are similar enough to MATLAB that you could modify the code to work as such.
%Peter's Spoke Length Calculator
disp('unless otherwise implied, all measurements are to be entered should be in mm, but typing "mm" afterward is not necessary')
D = input('What is the Effective Rim Diameter? ');
d = input('What is the Flange Diameter? ');
WL = input('What is the Left Flange Spacing (Center of Hub to Center of Left Flange) ');
WR = input('What is the Right Flange Spacing (Center of Hub to Center of Right Flange) ');
S = input('What is the Flange Hole Diameter? (Usually 2.4mm) ');
X = input('What is the Cross Pattern? (eg. 1 2 3 4; radial=0) ');
N = input('How many Spokes? ');
T = 2*pi*X/(N/2); %Spoke Angle
A = d/2*sin(T); %A = Spoke Position Offset
B = D/2 - d/2*cos(T); %B = Radial Component
C1 = WL; %C1 = Hub "Half Width"
C2 = WR; %C2 = Hub "Half Width"
LL = sqrt(A^2+B^2+C1^2) - S/2; %LL = Left Spoke Length
LR = sqrt(A^2+B^2+C2^2) - S/2; %LR = Right Spoke Length
fprintf('The Left Side Spoke Length Needed is %4.1f mm \n', LL)
fprintf('The Right Side Spoke Length Needed is %4.1f mm', LR)
The program works fine if you know all the measurements, and for most rims and hubs a quick google search will get you all the necessary dimensions if the manufacturer and model of rub and rim are known. But if you can't find the information online, or don't trust the source, then you must measure the rim and hub yourself. So I made a few metrics that show how to measure hubs and rims yourself, supposing you have an accurate set of calipers or a steady hand and a good ruler.
The flange diameter is measured from the center of a spoke hole on one side of the flange to the center of the spoke holes opposite that hole. So pick a hole and measure from the center of it to is opposite. To verify you are doing this accurately you should count 8 spoke holes between the two holes for a 36 hole hub, 7 spoke holes between the two for a 32 hole hub, 6 spoke holes between the two for a 28 hole hub, ... (N/4)-1 spoke holes for an N hole hub. The flange hole diameter is kind of hard to precisely measure so it is usually safe to assume it is 2.4mm.
A dimension that is particularly hard to measure, at least for rear hubs, is the distance from the center of the hub to the center of the left and right flanges. Here is one of many ways of measuring this:
Measure the OLD (over locknut distance -- which is usually 100mm for front hubs, 120mm for rear track hubs, 126mm for old rear road bike hubs, 130mm for modern road bike rear cassette hubs, 135mm for modern mountain bike rear cassette hubs, and can be all sorts of things for tandem & other unusual hubs), then measure distance "a" and distance "b," which is the distance from the end locknut to the center of the hub flange for both left and right sides respectively. The distance WL from the center of the hub to the center of the left flange is (OLD/2)-a and the distance WR from the center of the hub to the center of the right flange is (OLD/2)-b.
Another dimension that is particularly hard to measure is the effective rim diameter. The effective rim diameter is the diameter of the inner wall of the rim where the spoke heads sit. One way of measuring this is to drop a spoke nipple in the rim and measure the distance between the top of the nipple head and the outer rim diameter. I have done this by marking a spoke stuck down the hole into the nipple head then measuring the distance "x" from the end of the spoke to the mark. Subtracting this distance "x" from the outside rim diameter will give you ERD, the effective rim diameter.
Hope these are useful to someone.