As an edit to provide further clarification (to save you some reading) - we are trying to define the second diagram parametrically, so that the two flat parts are truncated and we are just left with the part we can use for the diagram. Hope this Helps! Thanks
Have taken an interest in the techniques employed in this question: How to draw two intersecting cylinders?.
Specifically, since I'm still learning Asymptote, I want to the the pgfplots method to diagram the intersection surface of three cylinders. I got a diagram of three intersecting cylinders to work by fiddling around with the code, but am stuck on creating their surface of intersection.
Here's the diagram I have of the intersecting cylinders for reference (with credit to the inspiration, of course.) - see MWE #1 at the bottom:
And this is what I've got so far (if I can solve for one part, then I can do the rest) - see MWE #2:
And what I want is something with this kind of shape, except corresponding to three cylinders instead of two - credit to Stewart:
MWE #1
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=3]
\begin{axis}[%
axis equal,
enlargelimits = true,
samples = 45, samples y = 45,
axis lines = none, ticks = none,
cyl/.style = {%
surf,
black!30!,
variable = \u,
variable y = \v,
z buffer = sort,
faceted color=black!70!,
},
%view/h = 125, view/v = 25
]
\addplot3[% (-) Z-SEMIAXIS
cyl,
domain = -3:3,
y domain = 0:360,
] ({cos(v)}, {sin(v)}, {min(u,abs(cos(v)),abs(sin(v)))});
\addplot3[% (-) X-SEMIAXIS
cyl,
domain = -3:3,
y domain = 0:360,
] ({min(u,-abs(cos(v)),-abs(sin(v)))}, {cos(v)}, {sin(v)});
\addplot3[% (+) Y-SEMIAXIS
cyl,
domain = 0:360,
y domain = -3:3,
] ({cos(u)}, {max(v,abs(cos(u)),abs(sin(u)))}, {sin(u)});
\addplot3[% (+) X-SEMIAXIS
cyl,
domain = -3:3,
y domain = 0:360,
] ({max(u,abs(cos(v)),abs(sin(v)))}, {cos(v)}, {sin(v)});
\addplot3[% (+) X-SEMIAXIS
cyl,
domain = -3:3,
y domain = 0:360,
] ({cos(v)}, {sin(v)}, {max(u,abs(cos(v)),abs(sin(v)))});
\addplot3[% (-) Y-SEMIAXIS
cyl,
domain = 0:360,
y domain = -3:3,
] ({cos(u)}, {min(-abs(cos(u)),-abs(sin(u)),v)}, {sin(u)});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
MWE #2
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=2]
\begin{axis}[%
axis equal,
enlargelimits = true,
samples = 45, samples y = 45,
axis lines = none, ticks = none,
cyl/.style = {%
surf,
black!30!,
variable = \u,
variable y = \v,
z buffer = sort,
faceted color=black!70!,
},
%view/h = 125, view/v = 25
]
\addplot3[% (-) Z-SEMIAXIS
cyl,
domain = -3:3,
y domain = 0:360,
restrict z to domain=-2:2,
] ({max(abs(u),cos(v))}, {sin(v)}, {u});
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Edit by @hpekristiansen:
Here is a picture of the intersection of three cylinders

Found here: https://abel.math.harvard.edu/archive/21a_summer_06/handouts/3cylinder.pdf





