我在极坐标中有一个点(110:2cm)
,但我想从这里向下画一条直线。
做的(110:1cm)
是沿 110 度向中心画一条线。如果不采取2*sin(110)
并2*cos(110)
找到明确的 x 和 y 位置,有没有办法从该位置向下画一条线?
答案1
使用 PSTricks:
选项1:
\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor
\begin{document}
\begin{pspicture}[showgrid](-2,-2)(2,2)
\qdisk(2;110){1pt}
\psline[origin={2;110}](0,-1)
\end{pspicture}
\end{document}
选项 2:
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}% \psrline is defined in this package but its documentation is explained in pst-node documentation, weird?
\begin{document}
\begin{pspicture}[showgrid](-2,-2)(2,2)
\qdisk(2;110){1pt}
\psrline(2;110)(0,-1)
\end{pspicture}
\end{document}
没有使用 PSTricks:
\documentclass[tikz,border=12pt]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (-2,-2) grid (2,2);
\fill (110:2) circle (1pt);
\draw (110:2) -- +(0,-1);
\end{tikzpicture}
\end{document}
TikZ 备注:
\draw (110:2) -- +(0,-1);
当前点为(110:2)
。它从点到点绘制一条线(110:2)
((110:2)+(0,-1)
矢量加法)。当前点仍在(110:2)
。\draw (110:2) -- ++(0,-1);
当前点为(110:2)
。它从点到点绘制一条线(110:2)
((110:2)+(0,-1)
矢量加法)。当前点移动到(110:2)+(0,-1)
。\draw (110:2) +(0,-1) -- +(0,1);
当前点是(110:2)
。它从点到点画一条线(110:2)+(0,-1)
。(110:2)+(0,1)
当前点仍然在(110:2)
。\draw (110:2) ++(0,-1) -- +(0,1);
当前点是(110:2)+(0,-1)
。它从点到点画一条线(110:2)+(0,-1)
。(110:2)+(0,-1)+(0,1)
当前点仍然在(110:2)+(0,-1)
。\draw (110:2) ++(0,-1) -- ++(0,1);
当前点为(110:2)+(0,-1)
。它从点 到(110:2)+(0,-1)
点画一条线(110:2)+(0,-1)+(0,1)
。当前点移动到(110:2)+(0,-1)+(0,1)
(等于(110:2)
)。\draw (110:2) ++(0,-1) (1,1) -- +(0,1);
当前点为(110:2)+(0,-1)
。不绘制任何内容,将当前点移动到(1,1)
。接下来,它从当前点(1,1)
到绘制一条线(1,1)+(0,1)
。当前点仍在(1,1)
。\draw (110:2) ++(0,-1) (1,1) -- ++(0,1);
当前点为(110:2)+(0,-1)
。不绘制任何内容,将当前点移动到。接下来,从当前点到(1,1)
绘制一条线。当前点移动到。(1,1)
(1,1)+(0,1)
(1,1)+(0,1)
答案2
既然你要求了。
代码
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{backgrounds} % for the grid
\tikzset{every picture/.append style={gridded,nodes={above,at end, font=\tiny}}} % example settings
\tikzset{
to y/.style={
to path={-- (\tikztostart|-0,\tikztotarget) \tikztonodes}},
to x/.style={
to path={-- (\tikztostart-|\tikztotarget,0) \tikztonodes}},
to y*/.style={
to path={-- (\tikztostart|-\tikztotarget) \tikztonodes}},
to x*/.style={
to path={-- (\tikztostart-|\tikztotarget) \tikztonodes}}
}
\begin{document}
\begin{tikzpicture}[]
\node at (0,0) {$(0,0)$};
\draw (110:2) node {(110:2)} -- ++ (down:1) node[midway,right] {I'm 1cm long.}; % this line is 1cm long
% also possible is (-90:1) or (90:-1) or (0,-1) or …
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$(0,0)$};
\draw (110:2) node {(110:2)} -- (110:2|-0,1) node[right] {Here is $y=1$}; % this line goes from (110:2cm) down where y = 1cm
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$(0,0)$};
\draw (110:3) node {(110:3)} to[to y] node[below] {$y=1.5$} (1.5) to[to x] node[above] {$x=0$} (0);
\end{tikzpicture}
\end{document}