I need to calculate the length of a belt (or chain or wire) around 2 circles (wheels, pulleys). The 2 circles will not be the same size. To do this I think I need to find the points on the circles where two lines are tangent to the circles.

One approach is as follows:
Let X1, Y1, and R1 be the center and radius of circle 1.
And X2, Y2, R2 for circle 2. Assume circle 1 is the smaller of the two and they do not intersect.
1. Draw a line(L1) from X2,Y2 thru X1,Y1 and extend it beyond the smaller circle. (This line is NOT the tangent line unless the circles are the same size.)
2. Draw a line(L2) thru X1,Y1 perpendicular to L1.
3. Draw a line(L3) thru X2,Y2 perpendicular to L1.
4. Draw a line(L4) thru the 2 points where the L2 crosses the edge of circle 1 and and L3 crosses edge of circle 2. Extend this line so it crosses L1 at Point P.
5. The distance from P along L1 to X1,Y1 is the same as the distance from P to the tangent on circle 1. Likewise for circle 2 giving the tangent segment.
6. Same as step 5 for the other tangent segment
7. Calculate total length of the belt as 2 * tangentsegment + contact arc on circle 1 + contact arc on circle 2.

My question is: Is this the best approach to this problem?
And, is this algorithm available in some programming language on the net?