如何求矢量和的角度

如何求矢量和的角度

(嘿大家,我想这是我在这里的第一个问题,所以我会尽力回答正确)

我正在尝试创建一个空间矢量正弦波。相量由三相的总和组成,但我无法获得空间矢量的实际角度(图像中的黑色相量)。 相量

我需要的:

  • 黑色箭头末端(vstip)相对于圆心(origo)的极坐标。

或者

  • 相对于原点的笛卡尔坐标,以及可以正确将这两个数字转换为角度的函数。(我不能单独使用 atan{},因为它对大于 90 的角度有一些限制)

代码:

 \documentclass[a4paper,landscape]{article}
\usepackage{pgfplots}
\usepackage{amsmath} % Required for \varPsi below
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}



%Definitions%
%===========================================================
\def \Vs {4}; %Magnitude of space vector in cm
\def \Angle {70}; %Angle with regards to phase A
\pgfmathsetmacro \Marker {\Angle/45)};
\pgfmathsetmacro \Vmax {\Vs * 2/3}; %Max phase voltage
\def \Axisheight {\Vmax *3};
\pgfmathsetmacro \Va {\Vmax * sin{(\Angle+0)}}; %Magnitude of phase A at angle \Angle
\pgfmathsetmacro \Vb {\Vmax * sin{(\Angle+120)}}; %Magnitude of phase B at angle \Angle
\pgfmathsetmacro \Vc {\Vmax * sin{(\Angle+240)}}; %Magnitude of phase C at angle \Angle
\pgfmathsetmacro \Radius {\Vmax}; %Radius of maximum line to line voltage output


%Locations%
%===========================================================
\def \OrigoX {-5 cm};
\def \OrigoY {0 cm};
\coordinate (origo) at (\OrigoX,\OrigoY); %Center of phasor diagram
\coordinate (phase_a) at (0:\Va cm); %Tip of phase A
\coordinate (phase_b) at (120:\Vb cm); %Tip of phase B
\coordinate (phase_c) at (240:\Vc cm) ; %Tip of phase C



%Circle background rings%
%===========================================================
\node at (origo) [circle,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Circle with radius 128% 
\node at (origo) [circle,draw=black!80,fill=green!0, inner sep=0pt,minimum size=\Vmax*2 cm, dashed] {}; %Circle with radius 100%

%Black guide lines with angle notation
\foreach \x in {45,90,...,360} {
    \draw[-,color=black,dotted, thin] (origo)  -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
} 

%Phasor guide lines%
%===========================================================
\draw[-,color=red] (origo)  -- ++(0:\Vmax cm)  coordinate (Y) node[anchor=west] {\large $i_a$};
\draw[-,color=blue] (origo) -- ++(120:\Vmax cm) node[anchor=south] {\large $i_b$};
\draw[-,color=green] (origo)  -- ++(240:\Vmax cm) node[anchor=north] {\large $i_c$};


%Actual phasors%
%===========================================================
\draw[->,color=red, very thick] (origo)  -- ++(phase_a); %Phase A phasor
\draw[->,color=blue, very thick] (origo)  -- ++(phase_b); %Phase B phasor
\draw[->,color=green, very thick] (origo)  -- ++(phase_c); %Phase C phasor

\draw[->,ultra thick,black] (origo) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstip); %Space vector resultant
\pgfgetlastxy{\XCoord}{\YCoord}; % X and Y coordinates of Space vector tip
\draw[->,color=blue, thin] (origo) ++(phase_a) -> ++(phase_b); %Resultant help lines
\draw[->,color=green, thin] (origo) ++(phase_a) ++(phase_b) -> ++(phase_c); %Resultant help lines


%Three phase sinusoidal voltages%
%===========================================================
\draw[color=red,thick,smooth,domain=0:8] plot(\x,{\Vmax * sin(\x*45)}); % Phase A
\draw[color=blue,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+120)}); %Phase B
\draw[color=green,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+240)}); % Phase C

\draw[->, color=black] (0,0) -- (9,0) node[anchor=west] {$\theta$}; %X axis
\draw[->, color=black] (0,-\Vs) -- (0,\Vs) node[anchor=south] {$V$}; %Y axis

\draw[color=red,dashed] (\Marker,\Va) -- (-0.3,\Va)  node[anchor=east] {$i_a$};; %A phase line to Y-axis
\draw[color=blue,dashed] (\Marker,\Vb)-- (-0.3,\Vb)  node[anchor=east] {$i_b$};; %B phase line to Y-axis
\draw[color=green,dashed] (\Marker,\Vc)-- (-0.3,\Vc)  node[anchor=east] {$i_c$};; %C phase line to Y-axis

\foreach \x in {1, 2,...,8} {
    \pgfmathsetmacro \tick {\x * 45};
    \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$}; %X Axis tick marks
    }


\draw[color=black] (\Marker cm, \Radius cm) -- (\Marker cm, -\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$}; %Marker

\draw[color=gray] (-5,\Vmax) -- (9,\Vmax) ; %X axis TOP
\draw[color=gray] (-5,-\Vmax) -- (9,-\Vmax) ; %X axis bottom
\draw[help lines] (0,-\Vs) grid (9 ,\Vs); %Grid

\end{tikzpicture}

\end{document}

答案1

\pgfmathanglebetweenpoints帮助:

\draw[->,ultra thick,black] (origo) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstip);

\pgfmathanglebetweenpoints{\pgfpointanchor{origo}{center}}
                          {\pgfpointanchor{Vstip}{center}}
\let\PhaseBlack\pgfmathresult

结果是宏中的相位\PhaseBlack:19.99997

相关内容