如何压缩 \foreach 命令?

如何压缩 \foreach 命令?
\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}

在此处输入图片描述

问题:我想让 \foreach 命令看起来更精巧。该怎么做?

答案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}

相关内容