# How to label or dimension a circle radius in TikZ?

I have a circle in the picture... How to add dimension of radius... form center of the circle to any point on the circle? Rotation is not giving what i want...

\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}

-
Is rotate around={45:(3,0)} instead of rotate=45 what you want? –  Qrrbrbirlbel Jan 2 '13 at 5:52
@Qrrbrbirlbel Yes it works... but text is always horizontal now... –  sandu Jan 2 '13 at 6:10
Qrrbrbirlbel: It works...Thanks... I added in Answer 2 –  sandu Jan 2 '13 at 6:48
sandu, we try to kep answers and questions separate, normally I'd ask that you add the solution as an answer rather than add it to the question, but in this case perhaps it would be better if @Qrrbrbirlbel adds the answer then you could accept it and give him some points:-) –  David Carlisle Jan 2 '13 at 7:33
Please don't insert my answer to your question. –  kiss my armpit Jan 2 '13 at 10:48

Another option is to use relative polar coordinates for the 45° line as in (3,0) -- ++(45:3) and the option slope to let the node rotated in the direction of the line, i.e. 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}

-
Why use 3$a$? –  Marc van Dongen Jan 2 '13 at 18:19
@MarcvanDongen: I don’t know I just copied from the other examples and didn’t feel like correcting it O:-) –  Tobi Jan 2 '13 at 22:27

For nodes rotate=<angle> rotates around their anchor, for everything else (?) it rotates around (0,0).

### rotate around

But there is the rotate around=<angle>:(<coordinate>) style!
(As always, if <coordinate> contains a comma (,), you’ll need to enclose the whole argument in braces { }.)

In this case you want

\draw[|->|, rotate around={45:(3,0)}] (3,0) -- (6,0)  node [midway,fill=white] {$3a$};


which will give you

### transform shape

But you want to rotate the node’s text too?

My initial go-to is transform shape, but this has tremendous consequences.

For example if you use another transformation like scale=0.5 (or yet another rotation). Normally, the nodes do not get affected by this, but in this case, they would:

I suppose you won’t want this, right?

Therefore, I suggest the use of an extra style (or two to be precise):

• rotate around with nodes=<angle>:<coordinate>

This style works like rotate around and thus forwards its arguments to this style. In addition it sets the \qrrNodeRotation macro to <angle>.

• rotate with is a style that should only be used on nodes on a path that is used with rotate around with nodes.

## Code

\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}


## Output

-
Another way to get this line is by means of relative polar coordinates: \draw[->|] (3,0) -- +(<angle>:3cm) node [midway,sloped] {$3a$}; –  Qrrbrbirlbel Jan 2 '13 at 10:50

Just for fun with 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}


-