TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen that we ca use \x1 and \y1 to access cartesian coordinates of point register \p1 declared in let.

Is there a way to access the polar coordinates (something like \a1 for the angle and \r1 for the distance) of the point \p1?

If not, what is the best way to do something like this :

\draw let \p1=(35:1cm) in (\a1+30,\r1) -- (\a1-30,2*\r1);
share|improve this question
Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – Werner Dec 4 '11 at 16:31
up vote 7 down vote accepted

I don't know if there is a direct register for that (and I would love to know too) but you can access that info with a little more work:

\draw[style=help lines] (0,0) grid[step=1cm] (3,2);
\draw[red,ultra thick] (0,0) -- (35:3cm);
\draw let \p1=(35:3cm), \n1 = {veclen(\x1,\y1)},\n2 = {atan2(\x1,\y1)} in (0,0) -- (\n2:\n1);
\draw let \p1=(35:1cm), \n1 = {veclen(\x1,\y1)},\n2 = {atan2(\x1,\y1)} in (0,0) -- (\n2+30:2*\n1);

This gives

enter image description here

One can further wrap this into a more pragmatic macro but it is not that verbose by itself now. Moreover, you can do the same with respect to another point, I mean it does not need to be the origin that the angle and length measured from.

share|improve this answer
Thanks. This works for me and is relatively easy to implement. So may be this is why \a1 and \r1 registers don't need to exist. – Kpym Dec 5 '11 at 7:54
A thanks from me as well, as it helped me solve a problem of my own (I hadn't realized you could do intermediate calculations with let like that.). – Torbjørn T. Dec 5 '11 at 8:56
@TorbjørnT. No problem, it's my pleasure. – percusse Dec 5 '11 at 12:52
Note for PGF/TiKz 3 : From version 3 the arguments of atan2 are (y,x) in order, and not (x,y). So the code must be adapted. – Kpym Dec 4 '14 at 10:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.