0

In this MWE there is tangent with help of the answer of @Jake in How do I make tangents to ellipses and lines parallel to these? But I do not succeed in using this point that I got by tangent=0.35 later on in order to connect it with F1 and F2. In other words: The blue and the black point on the ellipsis line should be the same but how can I get it exact without guessing the angle of the point where I've drawn the tangent?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.markings,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[
  dot/.style={draw,fill,circle,inner sep=1pt},
  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
  ]
  \def\a{4} % major half axis
  \def\b{2} % minor half axis
  \draw[thick, tangent=0.35] (0,0) ellipse ({\a} and {\b});
  \fill (tangent point-1) circle [radius=2pt];
  \draw [use tangent] (2,0) -- (-2,0);
  \def\angle{125} % angle for point on ellipse
  %Labelling the foci
  \node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
  \node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
  %Point on ellipsis
  \node[dot,label={\angle:$P$},blue] (P) at (\angle:{\a} and {\b}) {};
  \draw (F1) -- (P) (P) -- (F2);
\end{tikzpicture}
\end{document}

enter image description here

3
  • You can minimize a lot your code, using tkz-euclide.
    – SebGlav
    Jun 1, 2021 at 16:05
  • is your ellipse rotated? By the way, there is a tikz code here (geometric way) tex.stackexchange.com/a/540341/140722
    – Black Mild
    Jun 2, 2021 at 3:10
  • @Black Mild Thanks, that's elegant! (No, my ellipse is not rotated.)
    – ubuntuuser
    Jun 2, 2021 at 9:43

4 Answers 4

2

With a bit of help from tkz-euclide and in particular the bisector out macro, this is pretty straightforward. This is achievable in simple TikZ with calc library but here is a simple line to obtain the tangent.

tangent to an ellipse

\documentclass[tikz,border=3.14mm]{standalone}

\usepackage{tkz-euclide}
\usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt},]
        \def\a{4} % major half axis
        \def\b{2} % minor half axis
        \draw[thick] (0,0) ellipse ({\a} and {\b});
        
        \node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
        \node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
        \def\angle{125} % angle for point on ellipse
        \node[dot,label={\angle:$P$},blue] (P) at (\angle:{\a} and {\b}) {};
        \draw (F1) -- (P) -- (F2);
        
        \tkzDefLine[bisector out](F1,P,F2) \tkzGetPoint{K}
        \draw ($(K)!-2!(P)$)--($(P)!-2.5!(K)$);
          
    \end{tikzpicture}
\end{document}

I usually prefer to code everything in tkz-euclide when possible, but I thought that you would keep your original code instead.

2

While you are waiting for the TikZ cavalry, here is one I did earlier in Metapost for comparison.

enter image description here

Metapost has the useful concept of (fractional) points along a path. In the case of an ellipse there are 8 points starting at "3 o'clock".

  • point t of E gives you a pair of coordinates for the point
  • direction t of E gives you a pair that represents the tangent at that point

To get a nice line to draw I have used angle to find the rotation of the direction and applied it to a known line...

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
vardef focus(expr e, n) = 
  numeric a,b;
  a = arclength (point 0 of e .. center e);
  b = arclength (point 2 of e .. center e);
  ((a+-+b)/a)[center e, point if n=1: 4 else: 0 fi of e]
  enddef;

beginfig(1);

path E; E = fullcircle xscaled 233 yscaled 144 rotated 8; 
numeric t; t = 2.7182818;

z0 = point t of E;
z1 = focus(E,1);
z2 = focus(E,2);

path tangent; 
tangent = (left--right) scaled 42 
        rotated angle direction t of E
        shifted point t of E;

drawoptions(withcolor 3/4);
draw point 0 of E -- point 4 of E withcolor .7 white;
draw point 2 of E -- point 6 of E withcolor .7 white;

drawoptions(withcolor 3/4 red);
draw tangent;
draw z1 -- z0 -- z2;

drawoptions(withcolor 5/8 blue);
draw E;

drawoptions();
dotlabel.lrt(btex $F_1$ etex, z1);
dotlabel.lrt(btex $F_2$ etex, z2);
dotlabel.ulft(btex $P$   etex, z0);

endfig;
\end{mplibcode}
\end{document}

The supplied focus routine does the arithmetic to find you the focus points given an elliptical path. This is wrapped in luamplib so compile with lualatex.

2

A geometric method use the fact that the normal line at a point on a ellipse is the internal bisector of the angle from that point to two foci. A TikZ way is in here with the user-defined command bisectorpoint.

In Asymptote, bisector direction is a built-in command.

pair dir(path p, path q)
returns unit(dir(p)+dir(q)).

In particular,

pair Mn=M+dir(M--F1,M--F2); 
pair Mt=rotate(90,M)*Mn;

give the point Mn on the normal line and the point Mt on the tangent line at M of the ellipse.

enter image description here

unitsize(1cm);
real a=3, b=2;
real c=sqrt(a^2-b^2);
pair F1=(-c,0), F2=(c,0);
real t=130;
pair M=(a*Cos(t),b*Sin(t));  // a point on the ellipse
// M--Mn is the internal bisector of MF1 and MF2 
pair Mn=M+dir(M--F1,M--F2); 
pair Mt=rotate(90,M)*Mn;
dot(F1^^F2,gray);

draw((a+1,0)--(-a-1,0)^^(0,b+.5)--(0,-b-.5),gray);
draw(F1--M--F2,gray);
draw(ellipse((0,0),a,b));
draw(interp(M,Mt,-2)--interp(M,Mt,1.5),red);
draw(interp(M,Mn,-1)--interp(M,Mn,1.5),blue);

label("$F_1$",F1,S);
label("$F_2$",F2,S);
label("$M$",M+.4*dir(165));
1

Using tzplot:

enter image description here

\documentclass[border=1mm]{standalone} 

\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}[scale=1.4]
\def\a{4} % major half axis
\def\b{2} % minor half axis
\tzbbox(-4,-2)(4,2.2)
\settzdotsize{4pt}
\tzellipse[thick]"AA"(0,0)({\a} and {\b})
\tzvXpointat*{AA}{-2.5}(P){$P$}
\tztangent{AA}(P)[-4:-1]
\tzcoors*({-sqrt(\a*\a-\b*\b)},0)(F1){$F_1$}[b]({+sqrt(\a*\a-\b*\b)},0)(F2){$F_2$}[b];
\tzlines(F1)(P)(F2);   
\end{tikzpicture}    

\end{document}

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.