(编辑两次)我已经向自己澄清了我的问题,请允许我重申我的帖子。
我希望将一个角度 Angle(ABC)(实际上是一个向量)绕另一个角度 \alpha 旋转。要旋转的角度要么以其度数 \beta 表示,要么以三个点表示。前一种情况确实很容易。对于后一种情况,我似乎需要包来tkz-euclide
计算角度的度数。剩下的问题可能是:我可以不用吗tkz-euclide
?
(请参见下文了解我仍然存在的一些小的美容问题)。
欢迎您提出任何进一步的建议。
%\documentclass[convert={density=300,size=1080x800,outext=.png}]{standalone}
\documentclass[12pt,a4paper]{scrartcl} %%KOMA class
\setkomafont{sectioning}{\rmfamily\bfseries\boldmath} %%
\usepackage{amsmath,tkz-euclide}
\usepackage{tikz}
\usetkzobj{all}
\usepackage{calculator}
\usepackage{pgfplots}
\usetikzlibrary{rulercompass}
\usetikzlibrary{intersections,quotes,angles}
\usetikzlibrary{calc}
\newcommand\round[2][2]{\pgfmathprintnumber[precision=#1]{#2}}
\begin{document}
\pgfmathparse{30}
\pgfmathsetmacro\anglealpha{\pgfmathresult}
\pgfmathparse{170}
\pgfmathsetmacro\anglea{\pgfmathresult}
\pgfmathparse{150}
\pgfmathsetmacro\angleb{\pgfmathresult}
\pgfmathparse{135}
\pgfmathsetmacro\anglec{\pgfmathresult}
\begin{tikzpicture}[
myangle/.style args= {#1/#2}{draw=black!55,<->,
angle eccentricity=#1, angle radius=#2},
myangle/.default = 1.05/5cm
]
% grid
\draw [color=black!5] (-3,0) grid (7,8);
% axes
\draw[name path=A]
(0,0) coordinate[label=below left:{$(0,0)$}] (or) -- (0,8) node[below left] {$y$}
(or) -- (7,0) coordinate[label=below left:$x$] (x)
(or) -- (-3,0);
% red line
\path[ultra thick, draw=red]
(0,2) coordinate (m) -- ++(\anglealpha:5) coordinate[label={[label distance=1mm]345:$ww$}] (ww);
\draw
let
\p1=(0,2),\p2=(ww), \n1={{veclen(\x2-\x1,\y2-\y1)}}
in
(\x1,\y1) -- (\n1,\y1) coordinate[label={[label distance=1mm]345:$w$}] (w) {}
\pgfextra{\xdef\var{\n1}} ;
% vectors C's
\draw[name path=C0, ->] (w) to ["$\ell_0$", sloped, pos=0.8] ++ (\anglea:7) coordinate (c0) node[left] {$C_0$};
\draw[name path=C1, ->] (w) to ["$\ell_1$", sloped,pos=0.85] ++ (\angleb:6) coordinate (c1) node[left] {$C_1$};
\draw[name path=C2, ->] (w) to ["$\ell_2$", sloped,pos=0.8] ++ (\anglec:7) coordinate (c2) node[left] {$C_2$};
% rotated vectors
\draw[red,dashed,->] let \p1=($(w)-(c0)$),
\n1 = {veclen(\x1,\y1)} in
(ww) to ["$\ell_0$" ',text=red, pos=0.9] ++ (\anglea+\anglealpha:\n1) coordinate[label=left:$C_0^r$] (d0);
\draw[red,dashed,->] let \p1=($(w)-(c1)$),
\n1 = {veclen(\x1,\y1)} in
(ww) to ["$\ell_1$" ',text=red, pos=0.9] ++ (\angleb+\anglealpha:\n1) coordinate[label=left:$C_1^r$] (d1);
\draw[red,dashed,->] let \p1=($(w)-(c2)$),
\n1 = {veclen(\x1,\y1)} in
(ww) to ["$\ell_2$" ',text=red, pos=0.9] ++ (\anglec+\anglealpha:\n1) coordinate[label=left:$C_2^r$] (d2);
% angles
\draw pic[myangle, "$\alpha$"] {angle=w--m--ww} ;
\path pic[myangle=1.5/1.5cm, "$\beta_0$" ] {angle=c0--w--m} ;
\path pic[myangle=1.4/1.7cm, "$\beta_1$" ] {angle=c1--w--m} ;
\path pic[myangle=1.3/1.9cm, "$\beta_2$"] {angle=c2--w--m} ;
\path pic[myangle=1.5/1.5cm, "$\beta_0$" ] {angle=d0--ww--m} ;
\path pic[myangle=1.4/1.7cm, "$\beta_1$" ] {angle=d1--ww--m} ;
\path pic[myangle=1.3/1.9cm, "$\beta_2$" ] {angle=d2--ww--m} ;
% circles w, ww
\draw[fill=red!5] (ww) circle [radius=0.15] ;
\draw[fill=red!5] (w) circle [radius=0.15];
\end{tikzpicture}
\begin{tikzpicture}[
myangle/.style args= {#1/#2}{draw=black!55,<->, angle eccentricity=#1, angle radius=#2},
myangle/.default = 1.05/5cm]
% grid
\draw [color=black!5] (-3,0) grid (7,8);
% axes
\draw[name path=A] (0,0) coordinate[label=below left:{$(0,0)$}] (or) -- (0,8) node[below left] {$y$}
(or) -- (7,0) coordinate[label=below left:$x$] (x)
(or) -- (-3,0);
% red line
\path[ultra thick, draw=red]
(0,2) coordinate[label=below left:{$(0,2)$}] (m) -- ++(\anglealpha:5) coordinate[label={[label distance=1mm]345:$ww$}] (ww);
\draw pic[myangle, "$\alpha$", <->] {angle=w--m--ww} ;
\draw
let
\p1=(0,2),\p2=(ww), \n1={{veclen(\x2-\x1,\y2-\y1)}}
in
(\x1,\y1) -- (\n1,\y1) coordinate[label={[label distance=1mm]345:$w$}] (w) {}
\pgfextra{\xdef\var{\n1}} ;
\draw[name path=C3, ->] (w) to ["$\ell_3$", sloped, pos=0.8] (0.25,7) coordinate (c3) node[left] {$C_3$};
\tkzFindAngle(c3,w,m)
\tkzGetAngle{angleOne};
\FPround\angleOne\angleOne{0}
\tkzMarkAngle[size=.5](c3,w,m)
\tkzLabelAngle[pos=.82](c3,w,m){\tiny $\angleOne^\circ$}
% angle 0 from (ww) is line to the right, angle 90 is vertical, angle 180 is line on the left, 180+\alpha is red line, so 180+\alpha - \beta is the rotation of w--C3
\pgfmathparse{(180+\anglealpha)-\angleOne}
\pgfmathsetmacro\angletot{\pgfmathresult}
\draw[red,dashed,->]
let \p1=(w),\p2=(c3),
\n1 = {veclen(\x2-\x1, \y1-\y2)} in
(ww) to ["$\ell_3$",text=red, pos=0.8] ++(\angletot:\n1) coordinate[label=left:$C_3^r$] (d0);
\tkzFindAngle(m,ww,d0)
\tkzGetAngle{angleTwo}
\FPround\angleTwo\angleTwo{0}
\pgfmathparse{360-\angleTwo} % return decimal part .0 . How do I delete it?
\pgfmathsetmacro\angleTwo{\pgfmathresult}
\tkzMarkAngle[size=.5](d0,ww,m)
\tkzLabelAngle[pos=-.82](d0,ww,m){\tiny $\angleTwo^\circ$}
% circles w, ww
\draw[fill=red!5] (ww) circle [radius=0.15] ;
\draw[fill=red!5] (w) circle [radius=0.15];
\end{tikzpicture}
\end{document}
我仍然有几个外观问题:
- 我如何获取
46
而不是46.0
来自\pgfmathparse{360-\angleTwo}
? - 确实,为什么
\tkzFindAngle(m,ww,d0)
返回314
,和\tkzFindAngle(m,ww,d0)
分别-314
(而不是46)? - 我怎样在靠近弧顶的地方写标签 \betas ?
答案1
这是你想要的吗?
完整代码如下:
\documentclass[convert={density=300,size=1080x800,outext=.png}]{standalone}
%\documentclass[12pt,a4paper]{scrartcl} %%KOMA class
%\setkomafont{sectioning}{\rmfamily\bfseries\boldmath} %%
\usepackage{tikz}
\usepackage{calculator}
\usepackage{pgfplots}
\usetikzlibrary{rulercompass}
\usetikzlibrary{intersections,quotes,angles}
\usetikzlibrary{calc}
\newcommand\round[2][2]{\pgfmathprintnumber[precision=#1]{#2}}
\begin{document}
\begin{tikzpicture}
\draw [color=black!5] (0,0) grid (9,5);
\draw (9,0) coordinate (a) node[right, below] {x}
-- (0,0) coordinate (b) node[left] {(0,0)}
-- (0,5) coordinate (c) node[left] {y};
\path (0,0) coordinate (ad) -- (30:5cm) coordinate (dd);
\draw (ad) -- (dd) coordinate[pos=0.455](c1);
\coordinate (c2) at ($(c1)!2*2.365 cm!(dd)$);
\draw[->, ultra thick, red]
let
\p1=(ad),\p2=(c2), \n1={{veclen(\x2-\x1,\y2-\y1)}}
in
(\x1,\y1) -- (\x2,\y2)
\pgfextra{\xdef\var{\n1}} ;
\fill[black] (\var,0) circle (2.5pt)
pic["$\alpha$", draw=black!55, thick, <<->>, angle eccentricity=1.1, angle radius=\var]{angle=a--b--dd} ;
\draw[->, black] (0,0)coordinate(o) -- (\var ,0) coordinate (w);
\draw[->, black] (w) -- (0 ,3.5)coordinate(ww) [fill=black] node[left] {$C$};
\draw [fill=red!5] (w) circle [radius=0.25] node[xshift=-0.35cm, yshift=-0.45cm] {$w$}
pic["$\beta$", draw=black, <-, angle eccentricity=1.1, angle radius=3cm]{angle=w--o--c2};
\draw [fill=red!5] (c2) circle [radius=0.25] node[xshift=-0.35cm, yshift=-0.45cm] {$ww$};
\end{tikzpicture}
\end{document}
答案2
如果我理解正确的话,那么您正在寻找类似这样的东西:
即,您喜欢在w--b--ww
具有两个不同半径(外半径\alpha
和内半径\beta
)的之间绘制角度。为此,我认为没有必要对轨迹半径进行任何特殊的计算。此外,一些定义的坐标是重复的或未使用的(在下面的 MWE 中,我删除了所有这些坐标):
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, quotes}
\begin{document}
\begin{tikzpicture}[
myangle/.style args= {#1/#2}{draw=black!55,->,
angle eccentricity=#1, angle radius=#2},
myangle/.default = 1.05/5cm
]
% grid
\draw [color=black!5] (0,0) grid (7,4);
% axes
\draw (0,0) coordinate[label=below left:{$(0,0)$}] (b)
-- (0,4) node[below left] {$y$}
(b) -- (7,0) node[below left] {$y$};
% red line
\path[ultra thick, draw=red]
(b) -- (30:5) coordinate[label={[label distance=1mm]345:$ww$}] (ww)
( 0:5) coordinate[label={[label distance=1mm]345:$w$ }] (w);
% arrow C
\draw[->] (w) -- (ww -| b) node[left] {$C$};
% angles
\draw pic[myangle, "$\alpha$"] {angle=w--b--ww} ;
\path pic[myangle=1.1/2.5cm, "$\beta$" ] {angle=w--b--ww} ;
% circles w, ww
\draw[fill=red!5] (ww) circle [radius=0.25] ;
\draw[fill=red!5] (w) circle [radius=0.25];
\end{tikzpicture}
\end{document}
附录:
从您对问题的编辑中,我可以看出,在第一次尝试中我误解了您(但代码非常简单 :-) )。 现在代码不再那么简单了……因为需要计算由y
-axis 和 line的交点决定的矢量长度C
,对吗?:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{angles, calc, intersections, quotes}
\begin{document}
\begin{tikzpicture}[
myangle/.style args= {#1/#2}{draw=black!55,<->,
angle eccentricity=#1, angle radius=#2},
myangle/.default = 1.05/5cm
]
% grid
\draw [color=black!5] (-20,0) grid (7,4);
% axes
\draw[name path=A]
(0,0) coordinate[label=below left:{$(0,0)$}] (b)
-- (0,4) node[below left] {$y$}
(b) -- (7,0) coordinate[label=below left:$x$] (x);
% red line
\path[ultra thick, draw=red]
(b) -- (30:5) coordinate[label={[label distance=1mm]345:$ww$}] (ww)
( 0:5) coordinate[label={[label distance=1mm]345:$w$ }] (w);
% arrow C
\path[name path=C] (w) -- ++ (150:6);
\draw [name intersections={of=A and C, by={c}},->]
(w) to ["$\ell$" ',sloped,pos=0.4] (c) node[left] {$C$};
% arrow ?
\draw[red,dashed,->] let \p1=($(w)-(c)$),
\n1 = {veclen(\x1,\y1)} in
(ww) to ["$\ell$" ',text=black] ++ (180:\n1) coordinate[label=left:?] (d);
% angles
\draw pic[myangle, "$\alpha$"] {angle=w--b--ww} ;
\path pic[myangle=1.3/1.5cm, "$\beta$" ] {angle=c--w--b} ;
\path pic[myangle=1.3/1.5cm, "$\beta$" ] {angle=d--ww--b} ;
% circles w, ww
\draw[fill=red!5] (ww) circle [radius=0.25] ;
\draw[fill=red!5] (w) circle [radius=0.25];
\end{tikzpicture}
\end{document}