[Update: see version 2]
Have you ever want to join two tubes at some specific angle? For example, imagine you were building a bicycle frame. To ensure a good clean weld, you want to miter one of the tubes so that it perfectly fits against the surface of the other. This, unfortunately, can be a pain in the butt.
So, I created a quick and dirty ruby script to do the math for me. I enter the diameter of the two tubes, and the angle at which they should join, and it draws the curve as a postscript document. I can then print that template, tape it to the smaller tube, and cut along its length.
Say for instance I wanted to join two toilet paper rolls (1.75" diameter) at 30 degrees. I simply type:
$ ./pipemiter.rb 1.75 1.75 30 in >tp.ps
or, if you prefer something more guided and interactive,
$ ./pipemiter.rb >tp.ps
Preferred unit (one of mm, m, ft, in, cm): in
Outer Diameter of larger pipe: 1.75
Outer Diameter of smaller pipe: 1.75
Angle of joint (degrees): 30
and it gives me a postscript document, which looks like this curve on the right.
As a proof of principle, I tried it out with two toilet paper rolls
(to your left). They join perfectly!
The source code for the script is available for free.