Tikz 中的多切线

Tikz 中的多切线

我想绘制一个椭圆,上面画有大量切线。目前我的代码非常繁琐,无法绘制大量切线,而且切线越多,编译时间就越长。这是我当前的代码:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{luainputenc}
\makeatletter
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\makeatother

\usepackage{babel}
\begin{document}
\begin{tikzpicture}[
tangent/.style={
    decoration={
        markings,% switch on markings
        mark=
            at position #1
            with
            {
                \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
            }
    },
    postaction=decorate
},
use tangent/.style={
    shift=(tangent point-#1),
    x=(tangent unit vector-#1),
    y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
]
    \foreach \x in {0,0.05,...,1.1}
\draw [
tangent=0,
tangent=0.1,
tangent=0.2,
tangent=0.2,
tangent=0.3,
tangent=0.4,
tangent=0.5,
tangent=0.6,
tangent=0.7,
tangent=0.8,
tangent=0.9,
tangent=1.0,
tangent=1.1,
] (-0.25,0)
    to [out=-90,in=-90] (1.25,0)
    to [out=90,in=90] (-0.25,0);
\begin{scope}
\clip (0,0) circle (1.5);
\draw [thick, use tangent] (-3,0) -- (3,0);
\draw [thick, use tangent=2] (-3,0) -- (3,0);
\draw [thick, use tangent=3] (-3,0) -- (3,0);
\draw [thick, use tangent=4] (-3,0) -- (3,0);
\draw [thick, use tangent=5] (-3,0) -- (3,0);
\draw [thick, use tangent=6] (-3,0) -- (3,0);
\draw [thick, use tangent=7] (-3,0) -- (3,0);
\draw [thick, use tangent=8] (-3,0) -- (3,0);
\draw [thick, use tangent=9] (-3,0) -- (3,0);
\draw [thick, use tangent=10] (-3,0) -- (3,0);
\draw [thick, use tangent=11] (-3,0) -- (3,0);
\end{scope}
\draw (0,0) circle (1.5);
\fill (0,0) circle (0.1) (1,0) circle (0.1);
\end{tikzpicture}
\end{document}

代码生成了下面的图像,其中没有那么多切线。 在此处输入图片描述 所以我想要一种简单的方法来在圆内的椭圆周围绘制更多切线

答案1

通过一些代码重组;)

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{luainputenc}
\makeatletter
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\makeatother

\usepackage{babel}
\begin{document}
\begin{tikzpicture}[
tangent/.style={
    decoration={
        markings,% switch on markings
        mark=
            at position #1
            with
            {
                \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                \coordinate (tangent orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
            }
    },
    postaction=decorate
},
use tangent/.style={
    shift=(tangent point-#1),
    x=(tangent unit vector-#1),
    y=(tangent orthogonal unit vector-#1)
},
use tangent/.default=1
]
\begin{scope}
\clip (0,0) circle (1.5);
\foreach \x in {0,0.02,...,1.1}{
\draw [tangent=\x] (-0.25,0) to [out=-90,in=-90] (1.25,0) to [out=90,in=90] (-0.25,0);
\draw [thick, use tangent] (-3,0) -- (3,0);
}
\end{scope}
\draw (0,0) circle (1.5);
\fill (0,0) circle (0.1) (1,0) circle (0.1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容