3

I would like to draw an ellipse with a large number of tangents drawn on it. Currently my code is very tedious to draw a lot of tangents for and the compiling time takes considerably longer for more and more tangents. Here is my current code:

\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}

The code produces the following image, which is not that many tangents. enter image description here So I would like an easy way to draw more tangents around the ellipse inside the circle

5

With a bit of code reorganisation ;)

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.