我正在尝试使用 tikz 画一幅漂亮的草图。
我的 tikz 代码是这样的:
\documentclass[]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[allow upside down, scale=1]
%(0,0)(0.70,1.9)(1.41,3.6)
%\draw plot [smooth, tension=0.5] coordinates{(2.13,5.1)(2.86,6.4)(3.62,7.5)(4.42,8.4)(5.30,9.1)(6.34,9.6)(7.13,9.8)(8.42,9.9)}
\draw[red,line width=1pt] (2.13,5.1) -- (2.86,6.4) -- (3.62,7.5) -- (4.42,8.4) -- (5.30,9.1) -- (6.34,9.6) -- (7.13,9.8) -- (8.42,9.9) [smooth, tension=0.5]
node[sloped,inner sep=0cm,above,pos=.5,
anchor=south west,
minimum height=2cm,minimum width=1cm](N){};
\path (N.south west)
edge[->,blue] node[left] {$\vec{ n}$} (N.north west);
\end{tikzpicture}
\end{document}
大部分内容取自那里:如何在曲线上绘制切向量和分量向量 我的问题:
- 我如何定义法线向量的点?
- 我真的很喜欢那种顺畅...怎么样?
- 如何添加另一个矢量(相同目标,但其他角度)
当前代码的输出:
我正在尝试做的事情:
答案1
你必须把它放在
node
适当的位置:\draw[red,line width=1pt,smooth, tension=1.9,samples=1000] (2.13,5.1) -- node[sloped,inner sep=0cm,above,pos=.5, anchor=south west, minimum height=2cm,minimum width=1cm](N){}(2.86,6.4) -- (3.62,7.5) -- (4.42,8.4) -- (5.30,9.1) -- (6.34,9.6) -- (7.13,9.8) -- (8.42,9.9)node[black,above,anchor=west] {Frontwant};
您可以使用
rounded corners=<dimension>
。选择合适的<dimension>
。使用
calc
库,将x
值添加到(N.east)
。反转箭头方向:\path (N.south west) edge[stealth-,red!50!black,shorten <=2pt] ($(N.east) + (0.3,0)$) node[above=1.4cm] {$\hat{S}$};
改变
0.3
以($(N.east) + (0.3,0)$)
适合您想要的角度。
以上内容以及大量补充内容如下:
\documentclass[]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning}
\begin{document}
\begin{tikzpicture}[allow upside down, scale=1]
%(0,0)(0.70,1.9)(1.41,3.6)
%\draw plot [smooth, tension=0.5] coordinates{(2.13,5.1)(2.86,6.4)(3.62,7.5)(4.42,8.4)(5.30,9.1)(6.34,9.6)(7.13,9.8)(8.42,9.9)}
\draw [red,line width=1pt,smooth, tension=1.9,samples=1000,rounded corners=15pt] (2.13,5.1) -- node[sloped,inner sep=0cm,above,pos=.5,
anchor=south west,
minimum height=1cm,minimum width=0.5cm](N){}(2.86,6.4) -- (3.62,7.5) -- (4.42,8.4) -- (5.30,9.1) -- (6.34,9.6) -- (7.13,9.8) -- (8.42,9.9)node[black,above,anchor=west] {Frontwand}
;
%% vectors
\path (N.south west)
edge[-stealth,blue] node[below,pos=0.9] {$\vec{ n}$} (N.north west);
\path (N.south west) edge[stealth-,red!50!black,shorten <=2pt] node[above,pos=1,text=red!50!black] {$\hat{S}$ } ($(N.east) + (0,0.5)$);
%% horizontal lines and coordinates...
\path[draw,red!70!green] ($(N.south west) + (-2,0)$) -- ($(N.south west) + (7,0)$)node[coordinate, pos=0] (a){} node[coordinate,pos=1,label=right:{\color{black}$z$}] (b){} node[pos=.3,above=-0.1cm,black] {$A(z)$};
\path[draw,red!70!green] (a |- 2.86,6.4 ) -- (b |- 2.86,6.4)node[pos=1,anchor=west,black](c) {$z-1$}node[pos=.38,above=-0.1cm,black] {$A(z-1)$};
%% Co ordinate system
\node [right=1.5cm of b,scale=0.9] (O) {$\bigotimes$};
\draw[-latex](O.center) -- (c -| O)node[above]{$z$};
\draw[-latex](O.center) -- +(0:.7cm)node[right]{$x$};
\draw[-latex,shorten >= -5pt] (O.center) -- (O.north east) node[pos=1.8]{$y$};
\fill (N.south west) circle (2pt);
\fill (2.86,6.4) circle (2pt);
\end{tikzpicture}
\end{document}
虽然我没有优化代码,但可以省去很多输入工作。我让它变得更冗长。
答案2
另一次尝试借用 OP 的前 4 个坐标。
代码:
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\draw[black,thick] (-1,6.4)--(5,6.4) node[right]{$z-1$};
\draw[black,thick] (-1,5.1)--(5,5.1) node[right]{$z$};
\draw[black,thick,->] (7,5.5) node[label=below:$y$]{$\bigotimes$}-- (8,5.5)node[right]{$x$};
\draw[black,thick,->] (7,5.5) -- (7,6.5)node[right]{$z$};
\draw[black, line width=2pt] (1.7,4.1) -- (2.13,5.1) node[above right,xshift=5pt]{$A(z)$} -- (2.86,6.4) node[above right,xshift=5pt]{$A(z-1)$} -- (3.62,7.5) -- (4.42,8.4) node[above right]{Frontwand};
\draw[->,>=stealth',thick] (2.13,5.1) -- +(120:0.8cm) node[above left]{$n$};
\node[fill=black, circle, scale=0.5,pin={[pin distance=2cm,pin edge={<-,>=stealth'}]above:{$\hat S$}}] at (2.13,5.1){};
\node[fill=black, circle, scale=0.5] at (2.86,6.4){};
\end{tikzpicture}
\end{document}