3
\documentclass[border=15pt,pstricks,12pt]{standalone}
\usepackage{pstricks-add,pst-eucl}
\begin{document}
\foreach \i in {1,1.1,...,2.8,2.7,2.6,2.5,2.4,2.3,2.2,2.1,2,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1,1}{
    \begin{pspicture}(-4,-8)(4,8)%%

    \def\a{\i}
    \def\b{1}
    \def\h{\i}
    \def\x{0}
    \def\y{0}
    \pstGeonode[PosAngle={0,180,90}](+\x+\a,\y){A}(+\x-\a,\y){B}(\x,0|+\a,\x+\a*\h){M}
    \pstMiddleAB[PosAngle=-135]{A}{B}{C}
    \psellipticarc(C)(\a,\b){180}{0}
    \psellipticarc[linestyle=dashed](C)(\a,\b){0}{180}
    \pstSymO[PosAngle=-90]{C}{M}[D]
    \psEllipseTangents(C)(\a,\b)(M)
    \psline(EllipseT1)(M)(EllipseT2)
    \psEllipseTangents(C)(\a,\b)(D)
    \psline(EllipseT1)(D)(EllipseT2)
    \pstMiddleAB[PosAngle=0]{M}{A}{I}
    \pstMiddleAB[PosAngle=180]{M}{B}{J}
    \pstMiddleAB[PointName=none]{I}{J}{E}
    \psellipticarc(E)(+\a/2,\b/2){180}{0}
    \psellipticarc[linestyle=dashed](E)(+\a/2,\b/2){0}{180}
    \psEllipseTangents(E)(+\a/2,\b/2)(C)
    \psline[linestyle=dashed](EllipseT1)(C)(EllipseT2)
    \psLineSegments[linestyle=dashed](M)(D)(A)(B)(I)(J)
    \end{pspicture}
}
\end{document}

enter image description here

Question: I want to the \foreach command seems more delicate. How to do that?

  • \foreach \i in {1,1.1,...,2.8,2.7,2.6,2.5,2.4,2.3,2.2,2.1,2,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1,1} can be abbreviated to \foreach \i in {1,1.1,...,2.8,2.7,2.6,...,1}. P.S. It is a cool animation, so +1. ;-) –  Feb 16 '19 at 03:03
  • @marmot Thanks for your comment. My think is I want to use autoplay,palindrome for gif and I do not know that can or can't. :-) –  Feb 16 '19 at 03:21
  • You seem to have successfully generated a gif of that sort. Or how did you get the nice animation below your code? –  Feb 16 '19 at 03:26
  • @marmot It means I normally use \foreach \i in {1,1.1,...,2.8} for gif and it likes the loop optional of animate package. But here I prefer the palindrome optional to for it. –  Feb 16 '19 at 03:36
  • 1
    Is your question on foreach or how to convert a sequence of pdfs in a palindrome loop? If you convert the output of your code with convert -density 300 -delay 4 -loop 0 -alpha remove multipage.pdf animated.gif, as explained in https://tex.stackexchange.com/a/136919/121799, you will get a gif of the sort you show. (TikZ offers now tools to create animated svg's.) –  Feb 16 '19 at 03:39

1 Answers1

1
\documentclass[border=15pt,pstricks,12pt]{standalone}
\usepackage{pstricks-add,pst-eucl,pst-calculate}
\def\image#1{%
  \begin{pspicture}(-4,-8)(4,8)%%       
    \def\b{1}
    \def\h{#1}
    \def\x{0}
    \def\y{0}
    \pstGeonode[PosAngle={0,180,90}](+\x+#1,\y){A}(+\x-#1,\y){B}(\x,0|+#1,\x+#1*\h){M}
    \pstMiddleAB[PosAngle=-135]{A}{B}{C}
    \psellipticarc(C)(#1,\b){180}{0}
    \psellipticarc[linestyle=dashed](C)(#1,\b){0}{180}
    \pstSymO[PosAngle=-90]{C}{M}[D]
    \psEllipseTangents(C)(#1,\b)(M)
    \psline(EllipseT1)(M)(EllipseT2)
    \psEllipseTangents(C)(#1,\b)(D)
    \psline(EllipseT1)(D)(EllipseT2)
    \pstMiddleAB[PosAngle=0]{M}{A}{I}
    \pstMiddleAB[PosAngle=180]{M}{B}{J}
    \pstMiddleAB[PointName=none]{I}{J}{E}
    \psellipticarc(E)(+#1/2,\b/2){180}{0}
    \psellipticarc[linestyle=dashed](E)(+#1/2,\b/2){0}{180}
    \psEllipseTangents(E)(+#1/2,\b/2)(C)
    \psline[linestyle=dashed](EllipseT1)(C)(EllipseT2)
    \psLineSegments[linestyle=dashed](M)(D)(A)(B)(I)(J)
    \end{pspicture}}
\begin{document}

\multido{\r=1.0+0.1}{18}{\image{\r}}\multido{\r=2.8+-0.1}{19}{\image{\r}}

\end{document}