抛物线上的切线

抛物线上的切线

我确实花了很长时间研究这个问题。我需要一条抛物线上的切线;这是我的工作示例:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,intersections,decorations.markings}
\usepackage{relsize}
\begin{document}
\begin{tikzpicture}[
        ]
        \draw[very thick, ->, >=stealth', line join=miter]   (6,0) node(xline)[right] {$x_i$} -|
                          (0,6) node(yline)[above] {$y_i$};
            \draw[blue,thick,name path = line 1]          (4,1) coordinate () parabola (0,3);
            \draw[blue,thick,name path = line 2]         (4,2) coordinate ( ) parabola (0,4);
            \draw[blue,thick,name path = line 3]         (4,3) coordinate ( ) parabola (0,5);
            \draw[dashed ,name path = line 4](1,0) coordinate () -- (1,5);
            \draw[dashed ,name path = line 5](3,0) coordinate () -- (3,5);
            \fill[red,name intersections={of=line 1 and line 4}]     (intersection-1) circle (2pt) node { };
    \end{tikzpicture}
\end{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);
                }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
    },
    use tangent/.default=1
]
    \draw[thick, <->, line join = miter->]   (6,0) node(xline)[right] {$x_i$} -|
                      (0,6) node(yline)[above] {$y_i$};
\draw[dashed ,name path = line1](1,0) coordinate () -- (1,5);
\draw [blue,tangent=0.3,name path = line2] (4,1)    parabola  (0,3);
\fill[red,name intersections={of=line1 and line2}]     (intersection-1) circle (2pt) node {};
\draw [orange, thick, use tangent] (-1,0) -- (1,0) ;
\end{tikzpicture}

答案1

你只需要在目标点周围尽可能靠近地获取 2 个点,然后在它们之间画一条直线。此时它将是一条非常短的线,但随后你使用未记录的 tikz 选项shorten >shorten <使用负值,这意味着你正在延长而不是缩短线段。

在此处输入图片描述

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows, intersections}

\begin{document}

    \begin{tikzpicture}
        [ 
            extended line/.style={shorten >=-#1,shorten <=-3cm}
            , extended line/.default=1cm
        ]

        \clip (-2, -1) rectangle (7,8);

        \draw [very thick, <->, >=stealth', line join=miter]
            (6,0) node (xline)[right] {$x_i$} -|
            (0,7) node (yline) [above] {$y_i$}
        ;

        \draw [blue, ultra thick, name path = my parabola] (5,1) parabola (1,7);
        \draw [name path = my reference] (2,0) -- (2,5);

        \draw [dotted, name path = line 1] (4   , 0) -- (4   , 5);
        \draw [dotted, name path = line 2] (3   , 0) -- (3   , 5);
        \draw [dotted, name path = line 3] (2.01, 0) -- (2.01, 5);


        \fill [name intersections = {of = my parabola and my reference, name = my dot}];

        \fill [name intersections = {of = my parabola and line 1, name = i1}];
        \fill [name intersections = {of = my parabola and line 2, name = i2}];
        \fill [name intersections = {of = my parabola and line 3, name = i3}];

        \fill [red]    (i1-1) circle (1.1pt);
        \fill [orange] (i2-1) circle (1.1pt);
        \fill [black]  (i3-1) circle (1.1pt);

        \draw [red   , extended line             ] (my dot-1) -- (i1-1);
        \draw [orange, extended line = 2cm       ] (my dot-1) -- (i2-1);
        \draw [black , extended line = 4cm, thick] (my dot-1) -- (i3-1);

    \end{tikzpicture}
\end{document}

答案2

使用tzplot

在此处输入图片描述

\documentclass{standalone} 

\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}
\tzaxes(6,6){$x_i$}{$y_i$}
\tzparabola[blue,thick]"line 1"(4,1)(0,3)
\tzparabola[blue,thick]"line 2"(4,2)(0,4)
\tzparabola[blue,thick]"line 3"(4,3)(0,5)
\tzvfnat[dashed]"line 4"{1}[0:5]
\tzvfnat[dashed]"line 5"{3}[0:5]
% intersection
\tzXpoint*[red]{line 1}{line 4}(X)
% tangent
\tztangentat[blue]{line 1}{1}[0:2]
% tangent: more
\tztangentat[red]{line 3}{1}[0:2]
\tztangentat[red]{line 2}{3}(0.3,0.2)[2:5]
\end{tikzpicture}

\end{document}

相关内容