Circular and polygonal cylinders intersect in interesting 3D curves. Mathematica's built-in function RegionFunction shows that the cylinders make realistic pipe connections.

The parametric equation of a circular cylinder with radius inclined at an angle from the vertical is:

, with parameters and .

Define the functions and . The and functions define the composite curve of the -gonal cross section of the polygonal cylinder [1].

The parametric equation of a polygonal cylinder with sides and radius rotated by an angle around its axis is:

with parameters and .

To find the equation of the intersection curve, put . This gives the three equations:

,

,

.

These are equations with four variables, , , , and . Eliminating , , and by solving the equations gives the parametric curve of the intersection with θ as the only parameter (choosing gives the upper or lower half of the intersection curve):

.

Reference

[1] E. Chicurel-Uziel, "Single Equation without Inequalities to Represent a Composite Curve," Computer Aided Geometric Design, 21(1), 2004 pp. 23–42. doi:10.1016/j.cagd.2003.07.011.