# Derivation of Dan Hopper's TUBEFIT Algorithm

The derivation of TUBEFIT involves drawing a side view of two tubes with their centerlines intersecting at some arbitrary angle (AF). The assumed intersection curve where the ID of the CUT TUBE meets the OD of the UNCUT TUBE is then sketched on this drawing. What is desired is to calculate the Y OFFSET which is the distance down from the plane defined by the point where the centerlines of the two tubes intersect which is perpendicular to the centerline of the CUT TUBE. By choosing this intersection point as a reference, the CUT TUBE may be cut to a precise length to fit between two uncut tubes. This Y OFFSET as a function of distance around the OD of the CUT TUBE will allow calculation of a template to wrap around the tube to mark it for a perfect fit to the UNCUT TUBE. It will be seen that two hacksaw cuts will provide about 90 percent of the amount of cutting required with the remainder being ground or filed away -- all in a direction as viewed in Figure 1.

Figure 1. Intersection of CUT TUBE and UNCUT TUBE

To solve for the Y OFFSET (YO) two triangles are constructed as shown in Figure 1. A point where the two tubes meet is picked and labeled A. Right triangle ABC is constructed with one side perpendicular to the center line of the CUT TUBE. Notice that the angle at point C is the angle of fit (AF) between the tubes. Construct a second right triangle (CDE) from point C on the first triangle with one side perpendicular to the center line of the UNCUT TUBE. This time point D has the right angle, and point E has AF. The Y OFFSET from the plane of intersection is distance BE which is equal to EC - BC. If we solve the two triangles for lengths BC and EC, we will have a general equation for Y OFFSET. We eventually want this to be a function of the distance around the OD of the CUT TUBE for plotting the template. First we will solve for Y OFFSET as a function of angle ID which is easily converted to distance around the perimeter of the tube.

## Solution of Triangle ABC

If we choose 0 degrees to be on the right inside diameter of the CUT TUBE it will be seen that side AB has a length of RI*cos(ID) where RI is the inside radius of the CUT TUBE. The length of side BC is the unknown that we will solve for. Because all triangles have a total of 180 degrees, the angle at point A=90-AF. From trigonometry we know that TAN(angle)=OPPOSITE/ADJACENT. Or, OPPOSITE=TAN(angle)*ADJACENT. Therefore the solution of the first triangle for side CB is:
`CB=tan(90-AF)*RI*cos(ID) (Eq 1)`

## Solution of Triangle CDE

If we choose the bottom of the UNCUT TUBE in Figure 1 to be 0 degrees, then side CD=RU*cos(UC). From trigonomotry SIN(angle)=OPPOSITE/HYPOTENUSE. Or, HYPOTENUSE=OPPOSITE/SIN(angle). Therefore the solution of the second triangle for side CE is:
`CE=RU*cos(UC)/sin(AF) (Eq 2)`
Substituting Equations 1 and 2 into our original equation for YO:
`YO=CE-CB`
`YO=RU*cos(UC)/sin(AF)- tan(90-AF)*RI*cos(ID) (Eq 3)`

## Making RU a Function of RI

In order to get RU in terms of RI it is necessary to observe that whenever two tubes intersect, no matter what the angle of fit is, the angles of the larger (or same size) tube is a function of the angle of the smaller (or same size) tube. In other words, changing the angle between the tubes does not change where the angle lines of the tubes meet if we only looked at the angle values.

Figure 2. Relationship between the angles of the two tubes

From Figure 2 one can see that the relationship between these angles are as described in the following equations. This relationship is solved for RU*cos(UC) so that it may be substituted into Equation 3.
`RU*sin(UC)=RI*sin(ID) (Eq 4)`
Dividing both sides of the equation by RU:
`sin(UC)=(RI/RU)*sin(ID)`
From a trig identity: cos^2=1-sin^2. Therefore:
`cos(UC)=sqrt(1-((RI/RU)*sin(ID))^2)`
Multiplying both sides of the equation by RU:
`RU*cos(UC)=sqrt(RU^2-(RI*sin(ID))^2 (Eq 5)`

## First the General (Simple) Solution

Substituting Equation 5 into Equation 3:
`YO= sqrt(RU^2-(RI*sin(ID))^2) /sin(AF)- tan(90-AF)*RI*cos(ID) (Eq 6)`
If we want to mill or cut directly toward the ID from the OD at right angles to the tube centerline, then substituting OD for ID in Equation 6 will give the solution for YO as a function of angle OD. The only problem with this solution is that for angles other than 90 degrees, part of the OD of the CUT TUBE interferes with letting the ID touch the UNCUT TUBE. If we were to substitute RO for RI in Equation 6, and then take the greater of the Y OFFSET values for each angle for the template, this problem would be solved.

## Now the TUBEFIT Solution

The program TUBEFIT uses the following correction to Equation 6 to allow cutting the CUT TUBE with a hacksaw or flat grinding wheel which also automatically makes bevels for welding the tubes together. This modification is the real beauty of TUBEFIT. Figure 3 is a cross section of the CUT TUBE of Figure 1 looking at an end view.

Figure 3. Relationship of angle ID to angle OD for TUBEFIT solution

From Figure 3 it can be seen that:
`RI*cos(ID)=RO*cos(OD) (Eq 7)`
Dividing both sides of the equation by RI:
`cos(ID)=(RO/RI)*cos(OD)`
From the same identity as used earlier:
`(sin(ID))^2=1-((RO/RI)*cos(OD))^2`
Multiplying both sides of the equation by RI^2:
`(RI*sin(ID))^2=RI^2-(RO*cos(OD))^2 (Eq 8)`
Equations 7 and 8 may now be substituted into Equation 6 for the final TUBEFIT equation:
`YO= sqrt(RU^2- RI^2+(RO*cos(OD))^2) /sin(AF)- tan(90-AF)* RO*cos(OD) (Eq 9)`
In the program TUBEFIT Equation 9 is solved 180 times (every 2 degrees) around the CUT TUBE and plotted on the template. Reference lines are plotted at 90, 180 and 270 degrees as well as 2, 4 and 6 inches away from the intersection plane. These reference lines allow you to control the length and rotation of the CUT TUBE. They also enable you to fit a CUT TUBE to several UNCUT TUBES. In aircraft fuselage construction this is called a cluster. To do this you would make a template for each fit and mark the CUT TUBE, keeping the reference lines matched. Then the CUT TUBE would be cut to the minimum length of all the templates.

Daniel H. Hopper
Walton, IN

April 24, 2006