![直线与曲线的交点](https://linux22.com/image/319832/%E7%9B%B4%E7%BA%BF%E4%B8%8E%E6%9B%B2%E7%BA%BF%E7%9A%84%E4%BA%A4%E7%82%B9.png)
我想使用 \usetikzlibrary{intersections}
\documentclass[a4paper]{article}
\usepackage{amsmath,amsfonts,amssymb}
\usetikzlibrary{intersections,shapes}
\usepackage{esvect}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1]
%\draw [color=gray,help lines, step=.5] (-1.3,-1.3) grid (5.3,5.3);
\draw[-stealth ] (-1.3,0) -- (5.3,0) node[below] {\footnotesize $x$};
\draw[-stealth ](0,-1.3) -- (0,5.3) node[left] {\footnotesize $y$};
\draw (0pt,-10pt) node[left] {\footnotesize $0$};
\draw[ dashed] (0,1.9 )node[ left]{\footnotesize $f(b)$} -| (1.144,0)
node[below]{\footnotesize $b$} ;
\draw[ dashed] (0,3.1928)node[ left]{\footnotesize $f(a)$} -| (3.2 ,0)
node[ below]{\footnotesize $a$} ;
\pgfsetstrokecolor{rgb,1:red,1;green,0;blue,0}
\pgfsetlinewidth{1pt}
\pgfsetroundjoin \pgfpathmoveto{\pgfxy(0.582,0.7937)}
\pgfpathcurveto{\pgfxy(0.863,1.4009)}{\pgfxy(1.144,2.0082)}{\pgfxy(1.5608,2.328)}
\pgfpathcurveto{\pgfxy(1.9777,2.6479)}{\pgfxy(2.5303,2.6802)}{\pgfxy(2.9365,2.9365)}
\pgfpathcurveto{\pgfxy(3.3427,3.1928)}{\pgfxy(3.6026,3.6731)}{\pgfxy(3.8624,4.1534)}
\pgfstroke
\end{tikzpicture}%
\end{document}
答案1
你好,Khaled,您可以用 、 来命名您的路径name path=patha
。name path=pathb
然后找到patha
和pathb
相交的坐标name intersections={of=patha and pathb}
。其中交点命名为intersection-1
、intersection-2
、... 等等。
代码
\documentclass[a4paper]{article}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{esvect}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[>=stealth]
\draw[->](-1.3,0) -- (5.3,0) node[below] {\footnotesize $x$};
\draw[->](0,-1.3) -- (0,5.3) node[left] {\footnotesize $y$};
\node[below left]at(0,0) {\footnotesize $0$};
\draw[red,line width=1pt,name path=plot](0.5,0.5)..controls(1,3)and(3,2)..(4,4.5);
\node[below](a)at(1.2,0){$a$};
\node[below](b)at(3,0){$b$};
\path[name path=froma](a)--+(0,4);
\path[name path=fromb](b)--+(0,4);
\draw[dashed,name intersections={of=froma and plot}](a)--(intersection-1)--(0,0|-intersection-1)node[left]{f(a)};
\draw[dashed,name intersections={of=fromb and plot}](b)--(intersection-1)--(0,0|-intersection-1)node[left]{f(b)};
\end{tikzpicture}
\end{document}