Special thanks to joel_dunn@unc.edu for writing up the javascript.
The algorithm used is W=(L * (G^2))/R, where: