Lemniscate envelope

This Lemniscate envelope is generated by sweeping a circle, which has its center on a hyperbola.

This code was written by Pouya on TeX.SE.

LuaLaTeX is required.

Lemniscate envelope plot

\documentclass{article}
\usepackage[margin=0cm,a5paper,landscape]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=\paperwidth, height=\paperheight}
\usepackage{luacode}
\begin{luacode*}
  function getCenterRadius(t)
    a = 1;
    b = 1;
    h = 0;
    k = 0;
    cX = a*(1/math.cos(t)) + h;
    cY = b*math.tan(t) + k;
    R = math.sqrt((cX-h)^2 + (cY-k)^2) -- Classic
    return cX, cY, R
  end
  function printHyperbola()
    for t=-1.56,1.56,0.02555 do
        xL,yL,RL = getCenterRadius(t)
        xR,yR,RR = getCenterRadius(3.1415+t)
        tex.sprint("\\draw[very thin] (axis cs:"..(xL)..","..(yL)..") circle("..(RL*10)..");")
        tex.sprint("\\draw[very thin] (axis cs:"..(xR)..","..(yR)..") circle("..(RR*10)..");")
    end
  end
\end{luacode*}
\begin{document}
\noindent
  \begin{tikzpicture}
    \begin{axis}[xmin=-14.85, xmax=14.85, ymin=-10.5, ymax=10.5,
      hide axis,
    ]
    \directlua{printHyperbola()}
    \end{axis}
\end{tikzpicture}
\end{document}
Click to download: lemniscate-envelope.texlemniscate-envelope.pdf