22 January 2009

Easily miter tubes

[Update: see version 2]

Have you ever want to join two tubes at some specific Linkangle? 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.

Perfect 30degree miterAs 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.

9 comments:

Ken Junkins said...

Nice work. I will definately keep this tool available for when I do PVC tube joining. I often use PVC tubing in my set designs. Thanks.

Ken

Nick Johnson said...

Ken,

Stay tuned -- I've made some pretty massive improvements to the script. You could practically lay out all of the mitering for a bicycle frame now.

More soon.
Nick

Dennis Ferron said...

Sweet! Isn't Ruby just a joy for writing little scripts like this? Someone ought to make a Firefox plugin that lets the script execute in the browser if you click on a download link for a file ending in ".rb".

If you want to get really crazy, you could make the program accept coordinates of all the joints in X,Y,Z space, and print out the lengths and angles for all the pieces!

Anonymous said...

Awesome! Looking forward to new version!

Nick Johnson said...

Okay, the update has been posted, check it out!

Flemming said...

I while ago I find this site, for connection tubes.
Maybe you can use this for joining template
http://www.harderwoods.com/pipetemplate.php

Kind regards

Nick Johnson said...

@ Flemming -- Cool. Great minds think alike ;)

Tony said...

Pretty great. One issue that came up for me was trying to create a perpendicular miter. At first I used 90 degrees, thinking you were measuring angle with respect to the axis of the full tube and got some garbage output. I figured out you were measuring the angle with respect to a normal to that axis and went for a 0 degree angle and got a "no parallel tubes" error. I just put .000001 for the angle and got what I wanted. Just wanted to let you know of that little hitch.

The application is making a stationary bike for a human powered generator.

Nick Johnson said...

Tony,

That sounds really cool. I'd love to see it when it's done.

Are you starting with an old bike frame and making it stationary, or are you starting from scratch?

Nick