图片上有一个圆圈...如何添加半径尺寸...从圆心到圆上的任意一点?旋转没有得到我想要的结果...
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.0]
\draw [step=1.0,thin,gray!40] (0,-3) grid (6,3);
\fill[blue] (3,0) circle (2pt) node [black,,below left] {$C$};
%
\draw[thick] (3,0) circle(3);
\draw[|->|] (3,0) -- (6,0) node [midway,fill=white] {3$a$};
\draw[|->|,rotate=45] (3,0) -- (6,0) node [midway,fill=white] {3$a$};
\end{tikzpicture}
\end{document}
答案1
另一个选项是使用 45° 线的相对极坐标,(3,0) -- ++(45:3)
并选择slope
让节点沿线方向旋转,即node [midway,sloped,fill=white]
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.0]
\draw [step=1.0,thin,gray!40] (0,-3) grid (6,3);
\fill[blue] (3,0) circle (2pt) node [black,below left] {$C$};
%
\draw[thick] (3,0) circle(3);
\begin{scope}[>=latex]
\draw[->] (3,0) -- (6,0) node [midway,fill=white] {3$a$};
\draw[->] (3,0) -- ++(45:3) node [midway,sloped,fill=white] {3$a$};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
对于节点来说,它rotate=<angle>
围绕其锚点旋转,对于其他所有事物(?),它围绕旋转(0,0)
。
rotate around
但风格就是这样rotate around=<angle>:(<coordinate>)
!
(一如既往,如果<coordinate>
包含逗号 ( ,
),则需要将整个参数括在括号中{ }
。)
在这种情况下你想要
\draw[|->|, rotate around={45:(3,0)}] (3,0) -- (6,0) node [midway,fill=white] {$3a$};
这将给你
transform shape
但是您也想旋转节点的文本吗?
我的初次前往是transform shape
,但这会产生严重的影响。
例如,如果您使用另一个变换scale=0.5
(或另一个旋转)。通常,节点不会受到影响,但在这种情况下,它们会:
我想你不会想要这个,对吧?
因此,我建议使用一种额外的样式(或者准确地说是两种):
rotate around with nodes=<angle>:<coordinate>
此样式的工作方式类似于
rotate around
,因此将其参数转发给此样式。此外,它将\qrrNodeRotation
宏设置为<angle>
。rotate with
是一种仅应在与 一起使用的路径上的节点上使用的样式rotate around with nodes
。
代码
\documentclass[tikz,border=2pt]{standalone}
%\documentclass{article}\usepackage{tikz}
\tikzset{
rotate around with nodes/.style args={#1:#2}{
rotate around={#1:#2},
set node rotation={#1},
},
rotate with/.style={rotate=\qrrNodeRotation},
set node rotation/.store in=\qrrNodeRotation,
}
\begin{document}
\begin{tikzpicture}[scale=.5]% scale set to 0.5 for explanation %%%
\draw [step=1.0,thin,gray!40] (0,-3) grid (6,3);
\fill[blue] (3,0) circle (2pt) node [black,below left] {$C$};
\draw[thick] (3,0) circle (3cm);
\draw[|->|]
(3,0) -- (6,0) node [midway, fill=white] {$3a$};
\draw[|->|, rotate around with nodes={45:(3,0)}]
(3,0) -- (6,0) node [midway, fill=white, rotate with] {$3a$};
\end{tikzpicture}
\end{document}
输出
答案3
只是为了和 PSTricks 一起玩。
\documentclass[pstricks]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}[showgrid=bottom](6,6)
\pstGeonode[
PointName={C,none},
PointSymbol=none,
PosAngle=-135]
(3,3){C}
(6,3){B}
([nodesep=3,angle=60]C){A}
\pstCircleOA[dimen=outer]{C}{A}
\psset{arrows=|->,arrowinset=0}
\ncline{C}{A}\ncput*[nrot=60]{$3a$}
\ncline{C}{B}\ncput*{$3a$}
\end{pspicture}
\end{document}