如何使用 TikZ 绘制说明极坐标和直角坐标的矢量图?

如何使用 TikZ 绘制说明极坐标和直角坐标的矢量图?

我想知道如何修改下面的代码才能得到这张图片。我试图用对角线中的角度、箭头和元素将不同的概念组合在一起。任何帮助都非常感谢。

极坐标和直角坐标。

   \documentclass{article}
   \usepackage{tikz}  
   \begin{document}
   \begin{figure}
      \centering
        \begin{tikzpicture}[scale=1.25]
          \coordinate (A) at (-1.5cm,-1.cm);
          \coordinate (C) at (1.5cm,-1.0cm);
          \coordinate (B) at (1.5cm,1.0cm);
          \draw (A) -- node[below] {$E_{k}$} (B) -- node[right] {$f_{k}$} (C) -- node[below] {$e_{k}$} (A);
        \end{tikzpicture}
     \end{figure}
     \end{document}

答案1

使用 TikZ 进行几何和绘图的简短练习 :-) :

    \documentclass[tikz,
                    border=3mm]{standalone}
    \usetikzlibrary{angles, arrows.meta, quotes}

    \begin{document}
      \centering
    % added labels of vertex
        \begin{tikzpicture}[scale=1.25]
    \coordinate[label=below  left:A] (A) at (-1.5cm,-1.cm);
    \coordinate[label=below right:C] (C) at ( 1.5cm,-1.0cm);
    \coordinate[label=above right:B] (B) at ( 1.5cm, 1.0cm);
    \draw[-Stealth]  (A) edge ["$E_{k}$" '] (B) 
                     (A) edge ["$f_{k}$" '] (C) 
                     (C)  to  ["$e_{k}$" '] (B);
        \end{tikzpicture}

    % slightly improved your MWE, by use package "quotes" 
        \begin{tikzpicture}[scale=1.25]
    \coordinate[label=below  left:A] (A) at (-1.5cm,-1.cm);
    \coordinate[label=below right:C] (C) at ( 1.5cm,-1.0cm);
    \coordinate[label=above right:B] (B) at ( 1.5cm, 1.0cm);
    \draw[-Stealth]  (A) edge ["$E_{k}$",sloped] (B)
                     (A) edge ["$f_{k}$" '] (C)
                     (C)  to  ["$e_{k}$" '] (B);
        \end{tikzpicture}

    % coordinates and vectors determined by polar coordinates
        \begin{tikzpicture}[scale=1.25]
    \coordinate[label=below  left:A] (A) at (-1.5cm,-1.cm);
    \draw[-Stealth]  
        (A) to ["$E_{k}$",sloped] ++ ({atan(2/3)}:{sqrt(4+9)}) coordinate[label=above right:B] (B);
    \draw[-Stealth]
        (A) to ["$f_{k}$" ']      ++ (0:3)           coordinate[label=below right:C] (C);
    \draw[-Stealth]
        (C) to ["$e_{k}$" ']      ++ (90:2);
        \end{tikzpicture}

    % added angle label by help of package "angle"
        \begin{tikzpicture}[scale=1.25]
    \coordinate[label=below  left:A] (A) at (-1.5cm,-1.cm);
    \draw[-Stealth]
        (A) to ["$E_{k}$",sloped] ++ ({atan(2/3)}:{sqrt(4+9)})  coordinate[label=above right:B] (B);
    \draw[-Stealth] 
        (A) to ["$f_{k}$" ']      ++ (0:3)                      coordinate[label=below right:C] (C);
    \draw[-Stealth]
        (C) to ["$e_{k}$" ']      ++ (90:2);
    \pic ["$\angle\theta_i$", draw, angle radius = 12mm, angle eccentricity=1.3]     
        {angle = C--A--B};
        \end{tikzpicture}

     % added measure of magnitude
        \begin{tikzpicture}[scale=1.25]
    \coordinate[label=below  left:A] (A) at (-1.5cm,-1.cm);
    % vector from A in direction of angle "atan(2/3)" (arcus tangens" 
    % and magnitude "sgrt(2^2+2^2)" (square root)
    % end of vector determine coordinate B, which is labeled with "B" north east from it (above right)
    \draw[-Stealth]
        (A) to ["$\hat{V}_i$" '] ++ ({atan(2/3)}:{sqrt(4+9)})  coordinate[label=above right:B] (B);
    \draw[-Stealth]
        (A) to ["$f_{k}$" ']     ++ (0:3)                      coordinate[label=below right:C] (C);
    \draw[-Stealth]
        (C) to ["$e_{k}$" ']     ++ (90:2);
    % angle
    % drawn with syntax provided by package "angles", 
    % angles eccentricity determine label position
    % B--A--C is outer angle, C--A--B inner (sharp) angle
    \pic ["$\angle\theta_i$", draw, angle radius = 12mm, angle eccentricity=1.3]
        {angle = C--A--B};
    % magnitude
    % starting point of magnitude measure is determined by perpendicular distance of 3mm
    % from coordinate A calculated by "($(A)!3mm!90:(B)$)";
    % end point is determined with adding of vector magnitude and angle: "({atan(2/3)}:{sqrt(4+9)})"

\draw[{Bar[width=3.4mm]Straight Barb[]}-{Straight Barb[]Bar[width=3.4mm]}]
        ($(A)!3mm!90:(B)$) to ["$\vert\hat{V}_i\vert$",sloped] + ({atan(2/3)}:{sqrt(4+9)});          
        \end{tikzpicture}
    \end{document}

下面的图片来自 MWE 中的示例 1、2-3、4 和 5。

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

答案2

因为您在评论中提到TikZ解决方案似乎很神秘,所以我想给您一个Asymptote解决方案。该Asymptote语言与 有很多共同之处C++,因此对我来说不那么神秘。

include markers; // provides the markangle function

unitsize(2cm);

// define vertices
pair A = (-1.5,-1.0);
pair B = ( 1.5,-1.0);
pair C = ( 1.5, 1.0);

// draw and label triangle sides
draw(Label("$e_i$"), A--B, Arrow(HookHead));
draw(Label("$\hat{V}_i$"), A--C, Arrow(HookHead));
draw(Label("$f_i$"), B--C, Arrow(HookHead));

// define, draw, and label offset hypotenuse
real pathAngle = degrees(C-A);
path offsetPath = shift(rotate(pathAngle)*(0,0.2))*(A--C);
draw(Label(rotate(pathAngle)*"$\left|\hat{V}_i\right|$"), offsetPath, NW, Bars);

// draw and label the angle
markangle("$\angle\theta_i$", 50.0, B, A, C);

// label vertices
label("A", A, S);
label("B", B, S);
label("C", C, E);

在此处输入图片描述

相关内容