我想画一条圆的切线和法线,如下图所示:
我写的编码如下:
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\node (c) at (2,2) {$c$};
\coordinate (O) at (0,0);
\coordinate (A) at (2,2);
\coordinate (P) at (3,3.2);
\draw[->,thick] (-1,0)--(4,0) node[right]{$x$};
\draw[->,thick] (0,-1)--(0,4) node[above]{$y$};
\draw (O) node [below left]{$0$};
\draw (2, 2) circle[radius = 1.5cm];
\foreach \i in {45}{
\draw (2, 2) --++ (\i:1.5cm);
}
\draw [fill=black] (A) circle (1pt);
\end{tikzpicture}
\end{figure}
从而产生。
谁都行,请帮忙。
答案1
对于圆圈来说这非常容易。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth,font=\sffamily]
\path (2,2) coordinate[label=below:$c$](c);
\coordinate (O) at (0,0);
\coordinate (P) at (3,3.2);
\draw[->,thick] (-1,0)--(4,0) node[right]{$x$};
\draw[->,thick] (0,-1)--(0,4) node[above]{$y$};
\draw (O) node [below left]{$0$};
\draw (c) circle[radius = 1.5cm];
\foreach \i [count=\X] in {45}{
\draw (c) --++ (\i:1.5cm) coordinate (x\X);
\draw (x\X) -- ++ (\i:1) node[pos=0.8,below right]{normal}; % normal
\draw (x\X) ++ (\i+90:1) -- ++ (\i-90:2)
node[pos=0.9,above right]{tangent}; % tangent
}
\draw [fill=black] (c) circle (1pt);
\end{tikzpicture}
\end{document}
注意 Ti钾Z 提供了更多选项,例如tangent cs:
,请参阅部分13.2.4 切线坐标系pgfmanual v3.1.4。
答案2
(p1)--(p2)
要在点处绘制线的法线(p1)
,
\draw ($(p1)!1!-90:(p2)$) -- ($(p1)!1!90:(p2)$);
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\centering
\begin{tikzpicture}
\node (c) at (2,2) {$c$};
\coordinate (O) at (0,0);
\coordinate (A) at (2,2);
\coordinate (P) at (3,3.2);
\draw[->,thick] (-1,0)--(4,0) node[right]{$x$};
\draw[->,thick] (0,-1)--(0,4) node[above]{$y$};
\draw (O) node [below left]{$0$};
\draw (2, 2) circle[radius = 1.5cm];
\foreach \i in {45}{
\draw (2, 2) --++ (\i:1.5cm)coordinate(p\i){};
\draw ($(p\i)!1!-90:(2,2)$) -- ($(p\i)!1!90:(2,2)$);
}
\draw [fill=black] (A) circle (1pt);
\end{tikzpicture}
\end{document}