我使用以下代码绘制了两条彼此相切的曲线(不完全是,只是目测),有没有办法在点 $P$ 处绘制法线向量(向内和向外),如下所示?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[blue, very thick] (-2,10.5) .. controls (5,15.3) and (3,-0.2) .. (12.5,10.5);
\draw (-2,7.5) .. controls (5,15.5) and (4,0.5) .. (12.5,7.5)
node[sloped, inner xsep=25mm, inner ysep=0, fill, pos=0.5, red] (P) {}
node[ inner xsep=35mm, inner ysep=0, fill, pos=0.5, pink] (Q) {};
\filldraw (P) circle(2pt);
\end{tikzpicture}
\end{document}
答案1
通过使用decorations.markings
图书馆:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
bbox, % for better clip of image
decorations.markings}
\begin{document}
\begin{tikzpicture}[bezier bounding box,%
decoration = {markings,% switch on markings
mark= at position 0.5 with {
\node[dot];
\draw[red] (-3,0) -- (3,0);
\draw[-Straight Barb, magenta] (0,0) -- (0,2);
}
},
dot/.style = {circle, fill=black, inner sep=1.6pt,
node contents={}},
]
\draw[blue, very thick] (0,2) .. controls ++(4,4) and ++(-7.3,-7) .. (12, 2);
\draw[postaction={decorate}] (0,0) .. controls ++(4,4) and ++(-4.0,-4) .. (12, 0);
\end{tikzpicture}
\end{document}
注:Ti钾Z 通过建立包含曲线端点和两个控制点的最小矩形来确定(三次)贝塞尔曲线的边界框。库bbox
用于建立精确的边界框,(尽量)仅考虑曲线。
答案2
按照 Qrrbrbirlbel 的建议。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[%
vector/.pic={\draw [-latex, thick] (0,0) node [inner sep=2pt, fill, circle] {} -- (1,0);}
]
\draw[blue, very thick] (-2,10.5) .. controls (5,15.3) and (3,-0.2) .. (12.5,10.5);
\draw (-2,7.5) .. controls (5,15.5) and (4,0.5) .. (12.5,7.5)
pic [pos=0.5, sloped, red, scale=2] {vector}
pic [pos=0.5, sloped, rotate=90, magenta, scale=2] {vector};
\end{tikzpicture}
\end{document}
答案3
另一种解决方案。使用倾斜P
节点作为参考,从其中心到边界上的锚点绘制放大线。负片shorten
会放大它们。
注意:P
绘制节点是为了显示位置和方向。最终结果应取消绘制。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[blue, very thick] (-2,10.5) .. controls (5,15.3) and (3,-0.2) .. (12.5,10.5);
\draw (-2,7.5) .. controls (5,15.5) and (4,0.5) .. (12.5,7.5)
node[draw, sloped, pos=0.5, minimum size=5mm] (P) {}; %delete `draw` for final drawing
\filldraw (P) circle(2pt);
\draw[-latex, thick, shorten > = -15mm, red] (P.center)--(P.north);
\draw[-latex, thick, shorten > = -15mm, red] (P.center)--(P.east);
\end{tikzpicture}
\end{document}
答案4
使用tzplot
:
\documentclass{standalone}
\usepackage{tzplot}
\begin{document}
\begin{tikzpicture}
\tzbezier[blue, very thick]"AA"(-2,10.5)(5,15.3)(3,-0.2)(12.5,10.5)
\tzbezier"BB"(-2,7.5)(5,15.5)(4,0.5)(12.5,7.5)<node[pos=0.5](P){}>
\tzdot*(P)(4pt)
\tztangent[red,dashed,thick]{BB}(P)(.2,.1)[3:6.5]{tangent}[b,red]
\tznormal[->,thick,blue]{BB}(P)(.2,.1){3cm}{normal}[r]
\tznormal'[->,thick,red]{BB}(P)(.2,.1){3cm}{normal$'$}[b]
\tznormal[->,ultra thick,green,opacity=.7]{BB}(P)(.2,.1){10cm}[180]
\end{tikzpicture}
\end{document}