# How to draw straight line touching parabola and x-axis?

How to draw straight lines touching the parabola as follows: My coding looks like this

\begin{figure}[h!]
\centering
\begin{tikzpicture}
\coordinate (1) at (-3,-3);
\coordinate (2) at (3,3);
\coordinate (O) at (0,0);

\draw (-1.5,-3) node[below]{directrix};
\draw (-1.5,-3.4) node[below]{$x=-a$};
\draw (O) node[below left]{$(0,0)$};
\draw [fill=black] (1,0) circle (1.5pt);
\draw[thick, ->] (-3,0) -- (5,0) node[right]{$x$};
\draw[thick, ->] (0,-3) -- (0,3) node[above]{$y$};
\draw[dashed,very thin] (-1.3,-3)--(-1.3,3);
\draw[mirror=(1)--(2)] (-2,4) parabola bend (0,0) (2,4);
\draw (1,0) node[below]{$F(a,0)$};
\draw (0,0) node[above left]{$V$};
\end{tikzpicture}
\end{figure}


## 1 Answer

You could use the intersections library to find the intersection of the parabola and the horizontal line. (Of course, you could also determine the point analytically.)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\makeatletter
\tikzset{% https://tex.stackexchange.com/a/142491
mirror/.code={\pgfutil@in@{--}{#1}\ifpgfutil@in@\tikz@trans@mirror#1\@nil
\else\tikz@scan@one@point\pgftransformmirror#1\relax\fi},
ymirror/.code={\pgfutil@ifnextchar(\tikz@trans@ymirror@coordinate\tikz@trans@ymirror@simple#1\@nil},
xmirror/.code={\pgfutil@ifnextchar(\tikz@trans@xmirror@coordinate\tikz@trans@xmirror@simple#1\@nil}}
\def\tikz@trans@mirror#1--#2\@nil{%
\pgfextract@process\pgf@trans@mirror@A{\tikz@scan@one@point\pgfutil@firstofone#1}%
\pgfextract@process\pgf@trans@mirror@B{\tikz@scan@one@point\pgfutil@firstofone#2}%
\pgftransformMirror{\pgf@trans@mirror@A}{\pgf@trans@mirror@B}}
\def\pgftransformxmirror#1{\pgfmathparse{2*(#1)}\pgftransformcm{-1}{0}{0}{1}{\pgfqpoint{+\pgfmathresult pt}{+0pt}}}
\def\pgftransformymirror#1{\pgfmathparse{2*(#1)}\pgftransformcm{1}{0}{0}{-1}{\pgfqpoint{+0pt}{+\pgfmathresult pt}}}
\def\tikz@trans@ymirror@simple#1\@nil{
\pgfmathparse{#1}\let\tikz@temp\pgfmathresult
\ifpgfmathunitsdeclared
\pgftransformymirror{\tikz@temp pt}%
\else
\pgf@process{\pgfpointxy{0}{\tikz@temp}}%
\pgftransformymirror{+\the\pgf@y}%
\fi}
\def\tikz@trans@xmirror@simple#1\@nil{
\pgfmathparse{#1}\let\tikz@temp\pgfmathresult
\ifpgfmathunitsdeclared
\pgftransformxmirror{\tikz@temp pt}%
\else
\pgf@process{\pgfpointxy{\tikz@temp}{0}}%
\pgftransformxmirror{+\the\pgf@x}%
\fi}
\def\tikz@trans@xmirror@coordinate#1\@nil{\tikz@scan@one@point\pgfutil@firstofone#1\pgftransformxmirror{+\the\pgf@x}}
\def\tikz@trans@ymirror@coordinate#1\@nil{\tikz@scan@one@point\pgfutil@firstofone#1\pgftransformymirror{+\the\pgf@y}}
\def\pgftransformmirror#1{%
\pgfpointnormalised{#1}%
\pgf@xa=\pgf@sys@tonumber\pgf@y\pgf@x
\pgf@xb=\pgf@sys@tonumber\pgf@x\pgf@x
\pgf@yb=\pgf@sys@tonumber\pgf@y\pgf@y
\multiply\pgf@xa2\relax
\pgf@xc=-\pgf@yb\advance\pgf@xc\pgf@xb
\pgf@yc=-\pgf@xb\advance\pgf@yc\pgf@yb
\edef\pgf@temp{{\the\pgf@xc}{+\the\pgf@xa}{+\the\pgf@xa}{+\the\pgf@yc}}%
\expandafter\pgf@transformcm\pgf@temp{\pgfpointorigin}}
\def\pgftransformMirror#1#2{%
\pgfextract@process\pgf@trans@mirror@A{#1}%
\pgfextract@process\pgf@trans@mirror@B{#2}%
\pgfextract@process\pgf@trans@mirror@g{\pgfpointdiff{\pgf@trans@mirror@A}{\pgf@trans@mirror@B}}%
\pgftransformshift{\pgf@trans@mirror@A}%
\pgftransformmirror{\pgf@trans@mirror@g}%
\pgftransformshift{\pgfpointscale{-1}{\pgf@trans@mirror@A}}}
\makeatother
\begin{document}
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\coordinate (1) at (-3,-3);
\coordinate (2) at (3,3);
\coordinate (O) at (0,0);

\draw (-1.5,-3) node[below]{directrix};
\draw (-1.5,-3.4) node[below]{$x=-a$};
\path (O) node[below left]{$(0,0)$} node[above left]{$V$};
\draw [fill=black] (1,0) coordinate (F) circle (1.5pt)
node[below]{$F(a,0)$};
\draw[thick, ->] (-3,0) -- (5,0) node[right]{$x$};
\draw[thick, ->] (0,-3) -- (0,3) node[above]{$y$};
\draw[dashed,very thin] (-1.3,-3)--(-1.3,3);
\draw[mirror=(1)--(2),name path=parabola] (-2,4) parabola bend (0,0) (2,4);
\path[name path=hori] (-1.3,1.3) -- (current bounding box.east|-0,1.3);
\draw[name intersections={of=parabola and hori,by=i1}]
(-1.3,1.3) node[above left]{$N$} -- (i1) node[below right]{$P(x,y)$}
-- (F);
\end{tikzpicture}
\end{figure}
\end{document} BTW, it is always better to provide a complete code. I do not know whether or not I copied the mirror style from the correct place. (I am not sure if I understand you need it here. If it is only to draw the parabola, then it is not needed, but I am assuming you have other applications in mind.

• Noted. I will provide a complete next time. Thank you so much for your help. – Amirul Aizad Nov 11 '19 at 3:32