Tikz 绘图技术

Tikz 绘图技术
 \documentclass{article}

 \usepackage{geometry}
 \usepackage{amsmath}
 \usepackage{tikz}
 \usetikzlibrary{quotes,angles}
    
 \begin{document}

 \begin{center}
 \begin{tikzpicture}[scale=1,cap=round]
 \draw[style=help lines,step=1cm, dotted] (-0.9,-0.9) grid (9.9,7.9);

\draw[<->] (-0.9,0) -- (9.9,0) node[right] {$x$};
\draw[<->] (0,-0.9) -- (0,7.9) node[above] {$y$};
    
\coordinate (O) at (0,0);
    \coordinate (A) at (4,3);
    \coordinate (A1) at (4,0);
\coordinate (B) at (8,6);
    \coordinate (B1) at (8,0);

    \draw[thick,black,->,shorten >=-1.5cm] (O)--(B);
    
    \draw[fill] (O) circle (2pt) node[below left]{$O$};
    \draw[fill,blue] (A) circle (2pt) node[right=3pt] {\large $(x^{'},y^{'})$};
    \node at (A) [above] {$\textcolor{blue}{P^{'}}$};
    \draw[fill,red] (B) circle (2pt) node[right=3pt]{\large $(x,y)$};
    \node at (B) [above]{$\textcolor{red}{P}$};
    
    \draw[black] (4,.3)--(3.7,.3)--(3.7,0);
    \draw[black] (8,.3)--(7.7,.3)--(7.7,0);
    
    \draw[dashed,blue,thick] (A) -- (A1) node[below] {\large $A^{'}$};
    \draw[dashed,red,thick]  (B) -- (B1) node[below] {\large $A^{'}$};

    \draw pic["\textcolor{black}{\large $\theta$}", draw=black,thick, ->, angle eccentricity=1.2, angle radius=1cm]
{angle=A1--O--B};

    \end{tikzpicture} 
   \end{center}
   \end{document}

   outputs

在此处输入图片描述

 I'm trying to finish it to look like

在此处输入图片描述

答案1

使用相对坐标来放置缺失的内容。由于 OP' 位于 (4,3) 方向,因此垂直向量将位于 (-3,4) 方向。

将以下行添加到您的代码中

\draw (O) ++ (-3*0.03,4*0.03) --++ (-3*0.25,4*0.25);
\draw (A) ++ (-3*0.03,4*0.03) --++ (-3*0.075,4*0.075);
\draw (B) ++ (-3*0.03,4*0.03) --++ (-3*0.25,4*0.25);

\draw[blue,<->,>=latex] (O) ++ (-3*0.07,4*0.07) -- node[midway,above] {$r^{'}$}++ (4,3);
\draw[red,<->,>=latex] (O) ++ (-3*0.2,4*0.2) -- node[midway,above] {$r$}++ (8,6);

前三行绘制黑色分隔线。比例值(0.03、0.25 等)是近似值。您可以调整它们以调整线条的位置。

完整代码:

\documentclass{article}

 \usepackage{amsmath}
 \usepackage{tikz}
 \usetikzlibrary{quotes,angles}
    
 \begin{document}

 \begin{center}
 \begin{tikzpicture}[scale=1,cap=round]
 \draw[style=help lines,step=1cm, dotted] (-0.9,-0.9) grid (9.9,7.9);

\draw[<->] (-0.9,0) -- (9.9,0) node[right] {$x$};
\draw[<->] (0,-0.9) -- (0,7.9) node[above] {$y$};
    
\coordinate (O) at (0,0);
    \coordinate (A) at (4,3);
    \coordinate (A1) at (4,0);
\coordinate (B) at (8,6);
    \coordinate (B1) at (8,0);

    \draw[thick,black,->,shorten >=-1.5cm] (O)--(B);
    
    \draw[fill] (O) circle (2pt) node[below left]{$O$};
    \draw[fill,blue] (A) circle (2pt) node[right=3pt] {\large $(x^{'},y^{'})$};
    \node at (A) [above] {$\textcolor{blue}{P^{'}}$};
    \draw[fill,red] (B) circle (2pt) node[right=3pt]{\large $(x,y)$};
    \node at (B) [above]{$\textcolor{red}{P}$};
    
    \draw[black] (4,.3)--(3.7,.3)--(3.7,0);
    \draw[black] (8,.3)--(7.7,.3)--(7.7,0);
    
    \draw[dashed,blue,thick] (A) -- (A1) node[below] {\large $A^{'}$};
    \draw[dashed,red,thick]  (B) -- (B1) node[below] {\large $A^{'}$};

    \draw pic["\textcolor{black}{\large $\theta$}", draw=black,thick, ->, angle eccentricity=1.2, angle radius=1cm]
    {angle=A1--O--B};

    \draw (O) ++ (-3*0.03,4*0.03) --++ (-3*0.25,4*0.25);
    \draw (A) ++ (-3*0.03,4*0.03) --++ (-3*0.075,4*0.075);
    \draw (B) ++ (-3*0.03,4*0.03) --++ (-3*0.25,4*0.25);

    \draw[blue,<->,>=latex] (O) ++ (-3*0.07,4*0.07) -- node[midway,above] {$r^{'}$}++ (4,3);
    \draw[red,<->,>=latex] (O) ++ (-3*0.2,4*0.2) -- node[midway,above] {$r$}++ (8,6);

    \end{tikzpicture} 
   \end{center}
   \end{document}

相关内容